Skip to content

Commit

Permalink
Make the tests pass with all supported versions of rails
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Aug 16, 2019
1 parent 1860306 commit 72e9e21
Show file tree
Hide file tree
Showing 20 changed files with 57 additions and 119 deletions.
1 change: 0 additions & 1 deletion gemfiles/Gemfile-rails-5-2
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ source "https://rubygems.org"
gemspec path: ".."

gem "rails", github: 'rails/rails', branch: '5-2-stable'
gem 'mime-types', '< 3', require: false if RUBY_VERSION.start_with?('1.9')
3 changes: 0 additions & 3 deletions gemfiles/Gemfile-sass-3-1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,3 @@ else
gem "rails"
end
gem "sass", "~> 3.1.0"
gem "mime-types", "< 2"
gem "rack", "< 2" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "nokogiri", "~> 1.6.8" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1")
9 changes: 1 addition & 8 deletions gemfiles/Gemfile-sass-3-2
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,5 @@ source "https://rubygems.org"
# Specify your gem"s dependencies in sass-rails.gemspec
gemspec path: ".."

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "rails", "~> 4.2.0"
else
gem "rails"
end
gem "rails"
gem "sass", "~> 3.2.0"
gem "mime-types", "< 2"
gem "rack", "< 2" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "nokogiri", "~> 1.6.8" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1")
9 changes: 1 addition & 8 deletions gemfiles/Gemfile-sass-3-3
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,5 @@ source "https://rubygems.org"
# Specify your gem"s dependencies in sass-rails.gemspec
gemspec path: ".."

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "rails", "~> 4.2.0"
else
gem "rails"
end
gem "rails"
gem "sass", "~> 3.3.0"
gem "mime-types", "< 2"
gem "rack", "< 2" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "nokogiri", "~> 1.6.8" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1")
9 changes: 1 addition & 8 deletions gemfiles/Gemfile-sass-3-4
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,5 @@ source "https://rubygems.org"
# Specify your gem"s dependencies in sass-rails.gemspec
gemspec path: ".."

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "rails", "~> 4.2.0"
else
gem "rails"
end
gem "rails"
gem "sass", "~> 3.4.0"
gem "mime-types", "< 2"
gem "rack", "< 2" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "nokogiri", "~> 1.6.8" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1")
9 changes: 1 addition & 8 deletions gemfiles/Gemfile-sprockets-2-11
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ source "https://rubygems.org"
# Specify your gem"s dependencies in sass-rails.gemspec
gemspec path: ".."

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "rails", "~> 4.2.0"
else
gem "rails"
end
gem "rails"
gem "sprockets", "~> 2.11.0"
gem "sass", "~> 3.3.0"
gem "mime-types", "< 2"
gem "rack", "< 2" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "nokogiri", "~> 1.6.8" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1")
9 changes: 1 addition & 8 deletions gemfiles/Gemfile-sprockets-2-12
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ source "https://rubygems.org"
# Specify your gem"s dependencies in sass-rails.gemspec
gemspec path: ".."

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "rails", "~> 4.2.0"
else
gem "rails"
end
gem "rails"
gem "sprockets", "~> 2.12.0"
gem "sass", "~> 3.3.0"
gem "mime-types", "< 2"
gem "rack", "< 2" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "nokogiri", "~> 1.6.8" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1")
9 changes: 1 addition & 8 deletions gemfiles/Gemfile-sprockets-2-8
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ source "https://rubygems.org"
# Specify your gem"s dependencies in sass-rails.gemspec
gemspec path: ".."

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "rails", "~> 4.2.0"
else
gem "rails"
end
gem "rails"
gem "sprockets", "~> 2.8.0"
gem "sass", "~> 3.3.0"
gem "mime-types", "< 2"
gem "rack", "< 2" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "nokogiri", "~> 1.6.8" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1")
9 changes: 1 addition & 8 deletions gemfiles/Gemfile-sprockets-3-0
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ source "https://rubygems.org"
# Specify your gem"s dependencies in sass-rails.gemspec
gemspec path: ".."

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "rails", "~> 4.2.0"
else
gem "rails"
end
gem "rails"
gem "sprockets", "~> 3.0.0"
gem "sass", "~> 3.3.0"
gem "mime-types", "< 2"
gem "rack", "< 2" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "nokogiri", "~> 1.6.8" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1")
9 changes: 1 addition & 8 deletions gemfiles/Gemfile-sprockets-4-0
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,5 @@ source "https://rubygems.org"
# Specify your gem"s dependencies in sass-rails.gemspec
gemspec path: ".."

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "rails", "~> 4.2.0"
else
gem "rails"
end
gem "rails"
gem "sprockets", "~> 4.x"
gem 'mime-types', '< 3', require: false if RUBY_VERSION.start_with?('1.9')
gem "rack", "< 2" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "nokogiri", "~> 1.6.8" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1")
9 changes: 1 addition & 8 deletions gemfiles/Gemfile-sprockets-rails-2-2
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ source "https://rubygems.org"
# Specify your gem"s dependencies in sass-rails.gemspec
gemspec path: ".."

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "rails", "~> 4.2.0"
else
gem "rails"
end
gem "rails"
gem "sprockets-rails", "~> 2.2.0"
gem "sass", "~> 3.3.0"
gem "mime-types", "< 2"
gem "rack", "< 2" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "nokogiri", "~> 1.6.8" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1")
9 changes: 1 addition & 8 deletions gemfiles/Gemfile-sprockets-rails-master
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ source "https://rubygems.org"
# Specify your gem"s dependencies in sass-rails.gemspec
gemspec path: ".."

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "rails", "~> 4.2.0"
else
gem "rails"
end
gem "rails"
gem "sprockets-rails", github: "rails/sprockets-rails"
gem "sass", "~> 3.3.0"
gem "mime-types", "< 2"
gem "rack", "< 2" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2")
gem "nokogiri", "~> 1.6.8" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1")
4 changes: 4 additions & 0 deletions test/fixtures/alternate_config_project/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,9 @@ class Application < Rails::Application

# Enable the asset pipeline
config.assets.enabled = true

if Rails.gem_version < Gem::Version.new('6.0.0')
config.active_record.sqlite3.represent_boolean_as_integer = true
end
end
end
4 changes: 4 additions & 0 deletions test/fixtures/sass_project/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,9 @@ class Application < Rails::Application

# Prefer sass for generated assets.
config.sass.preferred_syntax = :sass

if Rails.gem_version < Gem::Version.new('6.0.0')
config.active_record.sqlite3.represent_boolean_as_integer = true
end
end
end
4 changes: 4 additions & 0 deletions test/fixtures/scss_project/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,9 @@ class Application < Rails::Application

# Enable the asset pipeline
config.assets.enabled = true

if Rails.gem_version < Gem::Version.new('6.0.0')
config.active_record.sqlite3.represent_boolean_as_integer = true
end
end
end
8 changes: 4 additions & 4 deletions test/sass_rails_generators_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ScaffoldGeneratorTest < Sass::Rails::TestCase
generate_scaffold
assert_file_exists "app/assets/stylesheets/foos.scss"
assert_file_exists "app/assets/stylesheets/scaffolds.scss"
assert_not_output /conflict/
assert_not_output(/conflict/)
end
end

Expand All @@ -15,7 +15,7 @@ class ScaffoldGeneratorTest < Sass::Rails::TestCase
generate_scaffold
assert_file_exists "app/assets/stylesheets/foos.sass"
assert_file_exists "app/assets/stylesheets/scaffolds.sass"
assert_not_output /conflict/
assert_not_output(/conflict/)
end
end

Expand All @@ -24,7 +24,7 @@ class ScaffoldGeneratorTest < Sass::Rails::TestCase
generate_scaffold "--stylesheet-engine=scss"
assert_file_exists "app/assets/stylesheets/engine_project/foos.scss"
assert_file_exists "app/assets/stylesheets/scaffolds.scss"
assert_not_output /conflict/
assert_not_output(/conflict/)
end
end

Expand All @@ -33,7 +33,7 @@ class ScaffoldGeneratorTest < Sass::Rails::TestCase
generate_scaffold "--stylesheet-engine=sass"
assert_file_exists "app/assets/stylesheets/engine_project/foos.sass"
assert_file_exists "app/assets/stylesheets/scaffolds.sass"
assert_not_output /conflict/
assert_not_output(/conflict/)
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/sass_rails_logger_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SassRailsLoggerTest < Sass::Rails::TestCase
"Sass::logger.log_level = :#{level}; Sass::logger.log(:#{level}, %Q|#{message}|)"
end

assert File.exists?("#{app_root}/log/development.log"), "log file was not created"
assert File.exist?("#{app_root}/log/development.log"), "log file was not created"

log_output = File.open("#{app_root}/log/development.log").read
assert log_output.include?(message), "the #{level} log message was not found in the log file"
Expand Down
56 changes: 28 additions & 28 deletions test/sass_rails_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SassRailsTest < Sass::Rails::TestCase
"puts Rails.application.config.sass.style"
end

assert_output /compact/
assert_output(/compact/)
end
end

Expand Down Expand Up @@ -42,7 +42,7 @@ class SassRailsTest < Sass::Rails::TestCase
"puts Rails.application.config.assets.css_compressor"
end

assert_output /yui/
assert_output(/yui/)
end
end

Expand All @@ -52,7 +52,7 @@ class SassRailsTest < Sass::Rails::TestCase
"puts Rails.application.config.sass.style"
end

assert_output /expanded/
assert_output(/expanded/)
end
end

Expand Down Expand Up @@ -101,45 +101,45 @@ class SassRailsTest < Sass::Rails::TestCase
css_output = asset_output('css_application.css')
assert_match /globbed/, css_output

if File.exists?("#{app_root}/log/development.log")
if File.exist?("#{app_root}/log/development.log")
log_file = "#{app_root}/log/development.log"
elsif File.exists?("#{app_root}/log/test.log")
elsif File.exist?("#{app_root}/log/test.log")
log_file = "#{app_root}/log/test.log"
else
flunk "log file was not created"
end

log_output = File.open(log_file).read
refute_match /Warning/, log_output
refute_match(/Warning/, log_output)
end
end

test 'sass imports work correctly' do
css_output = sprockets_render('scss_project', 'application.css')
assert_match /main/, css_output
assert_match /top-level/, css_output
assert_match /partial-sass/, css_output
assert_match /partial-scss/, css_output
assert_match /sub-folder-relative-sass/, css_output
assert_match /sub-folder-relative-scss/, css_output
assert_match /not-a-partial/, css_output
assert_match /globbed/, css_output
assert_match /nested-glob/, css_output
assert_match /plain-old-css/, css_output
assert_match /another-plain-old-css/, css_output
assert_match /without-css-ext/, css_output
assert_match /css-erb-handler/, css_output
assert_match /scss-erb-handler/, css_output
assert_match /sass-erb-handler/, css_output
assert_match /css-sass-erb-handler/, css_output
assert_match /css-scss-erb-handler/, css_output
assert_match /default-old-css/, css_output
assert_match(/main/, css_output)
assert_match(/top-level/, css_output)
assert_match(/partial-sass/, css_output)
assert_match(/partial-scss/, css_output)
assert_match(/sub-folder-relative-sass/, css_output)
assert_match(/sub-folder-relative-scss/, css_output)
assert_match(/not-a-partial/, css_output)
assert_match(/globbed/, css_output)
assert_match(/nested-glob/, css_output)
assert_match(/plain-old-css/, css_output)
assert_match(/another-plain-old-css/, css_output)
assert_match(/without-css-ext/, css_output)
assert_match(/css-erb-handler/, css_output)
assert_match(/scss-erb-handler/, css_output)
assert_match(/sass-erb-handler/, css_output)
assert_match(/css-sass-erb-handler/, css_output)
assert_match(/css-scss-erb-handler/, css_output)
assert_match(/default-old-css/, css_output)
end

test 'sprockets directives are ignored within an import' do
css_output = sprockets_render('scss_project', 'import_css_application.css')
assert_match /\.css-application/, css_output
assert_match /\.import-css-application/, css_output
assert_match(/\.css-application/, css_output)
assert_match(/\.import-css-application/, css_output)
end

test 'globbed imports work when new file is added' do
Expand All @@ -155,7 +155,7 @@ class SassRailsTest < Sass::Rails::TestCase
end

css_output = asset_output(filename)
assert_match /new-file-test/, css_output
assert_match(/new-file-test/, css_output)
end
end

Expand All @@ -172,7 +172,7 @@ class SassRailsTest < Sass::Rails::TestCase
end

css_output = asset_output(filename)
assert_match /changed-file-test/, css_output
assert_match(/changed-file-test/, css_output)
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/support/sass_rails_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def asset_output(filename)
end

def assert_file_exists(filename)
assert File.exists?(filename), "could not find #{filename}. PWD=#{Dir.pwd}\nDid find: #{Dir.glob(File.dirname(filename)+"/*").join(", ")}"
assert File.exist?(filename), "could not find #{filename}. PWD=#{Dir.pwd}\nDid find: #{Dir.glob(File.dirname(filename)+"/*").join(", ")}"
end

def assert_not_output(match)
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
if possible_dev_dependencies.include?(s.name)
gem_path = s.full_gem_path
gem_options = { version: s.version }
gem_options[:path] = gem_path if File.exists?("#{gem_path}/#{s.name}.gemspec")
gem_options[:path] = gem_path if File.exist?("#{gem_path}/#{s.name}.gemspec")
$gem_options[s.name] = gem_options
end
end
Expand Down

0 comments on commit 72e9e21

Please sign in to comment.