Skip to content

Commit c0ae66f

Browse files
author
Francesco Rodriguez
committed
fix tests
1 parent c861072 commit c0ae66f

File tree

3 files changed

+24
-59
lines changed

3 files changed

+24
-59
lines changed

test/fixtures/alternate_config_project/config/environments/production.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# Code is not reloaded between requests
55
config.cache_classes = true
66

7+
config.eager_load = true
8+
79
# Full error reports are disabled and caching is turned on
810
config.consider_all_requests_local = false
911
config.action_controller.perform_caching = true

test/fixtures/alternate_config_project/config/environments/test.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,4 @@
3535

3636
# Print deprecation notices to the stderr
3737
config.active_support.deprecation = :stderr
38-
39-
# Set to compact only for testing purposes.
40-
config.sass.style = :compact
4138
end

test/sass_rails_test.rb

Lines changed: 22 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,46 @@
11
require 'test_helper'
22

33
class SassRailsTest < Sass::Rails::TestCase
4-
test "classes are loaded" do
4+
test 'classes are loaded' do
55
assert_kind_of Module, Sass::Rails
6-
assert_kind_of Class, Sass::Rails::CssCompressor
76
assert_kind_of Class, Sass::Rails::Railtie
87
end
98

10-
test 'style config item is honored' do
9+
test 'style config item is honored in development mode' do
1110
within_rails_app 'alternate_config_project' do
12-
runcmd "ruby script/rails runner 'puts Rails.application.config.sass.style'", Dir.pwd, true, "Gemfile", {"RAILS_ENV" => "development"}
11+
runcmd "ruby script/rails runner 'puts Rails.application.config.sass.style'", Dir.pwd, true, 'Gemfile', {'RAILS_ENV' => 'development'}
1312
assert_output /compact/
1413
end
1514
end
1615

16+
test 'style config item is not honored if environment is not development' do
17+
within_rails_app 'alternate_config_project' do
18+
runcmd "ruby script/rails runner 'p Rails.application.config.sass.style'", Dir.pwd, true, 'Gemfile', {'RAILS_ENV' => 'production'}
19+
assert_equal 'nil', $last_ouput.chomp
20+
end
21+
end
22+
1723
test 'css_compressor config item is not honored in development mode' do
1824
within_rails_app 'alternate_config_project' do
19-
runcmd "ruby script/rails runner 'p Rails.application.config.assets.css_compressor'", Dir.pwd, true, "Gemfile", {"RAILS_ENV" => "development"}
25+
runcmd "ruby script/rails runner 'p Rails.application.config.assets.css_compressor'", Dir.pwd, true, 'Gemfile', {'RAILS_ENV' => 'development'}
2026
assert_equal 'nil', $last_ouput.chomp
2127
end
2228
end
2329

2430
test 'css_compressor config item is honored if environment is not development' do
2531
within_rails_app 'alternate_config_project' do
26-
runcmd "ruby script/rails runner 'puts Rails.application.config.assets.css_compressor'", Dir.pwd, true, "Gemfile", {"RAILS_ENV" => "production"}
32+
runcmd "ruby script/rails runner 'puts Rails.application.config.assets.css_compressor'", Dir.pwd, true, 'Gemfile', {'RAILS_ENV' => 'production'}
2733
assert_output /yui/
2834
end
2935
end
3036

3137
test 'sass uses expanded style by default in development mode' do
3238
within_rails_app 'scss_project' do
33-
runcmd "ruby script/rails runner 'puts Rails.application.config.sass.style'", Dir.pwd, true, "Gemfile", {'RAILS_ENV' => 'development'}
39+
runcmd "ruby script/rails runner 'puts Rails.application.config.sass.style'", Dir.pwd, true, 'Gemfile', {'RAILS_ENV' => 'development'}
3440
assert_output /expanded/
3541
end
3642
end
3743

38-
test 'sass uses compressed style by default in test mode' do
39-
within_rails_app 'scss_project' do
40-
runcmd "ruby script/rails runner 'puts Rails.application.config.sass.style'", Dir.pwd, true, 'Gemfile', {'RAILS_ENV' => 'test'}
41-
assert_output /compressed/
42-
end
43-
end
44-
45-
test 'sass uses compressed style by default in production mode' do
46-
within_rails_app 'scss_project' do
47-
runcmd "ruby script/rails runner 'puts Rails.application.config.sass.style'", Dir.pwd, true, 'Gemfile', {'RAILS_ENV' => 'production'}
48-
assert_output /compressed/
49-
end
50-
end
51-
5244
test 'sass not defines compressor in development mode' do
5345
within_rails_app 'scss_project' do
5446
runcmd "ruby script/rails runner 'p Rails.application.config.assets.css_compressor'", Dir.pwd, true, 'Gemfile', {'RAILS_ENV' => 'development'}
@@ -59,42 +51,24 @@ class SassRailsTest < Sass::Rails::TestCase
5951
test 'sass defines compressor by default in test mode' do
6052
within_rails_app 'scss_project' do
6153
runcmd "ruby script/rails runner 'puts Rails.application.config.assets.css_compressor'", Dir.pwd, true, 'Gemfile', {'RAILS_ENV' => 'test'}
62-
assert_output /Sass::Rails::CssCompressor/
54+
assert_equal 'sass', $last_ouput.chomp
6355
end
6456
end
6557

6658
test 'sass defines compressor by default in production mode' do
6759
within_rails_app 'scss_project' do
6860
runcmd "ruby script/rails runner 'puts Rails.application.config.assets.css_compressor'", Dir.pwd, true, 'Gemfile', {'RAILS_ENV' => 'production'}
69-
assert_output /Sass::Rails::CssCompressor/
61+
assert_equal 'sass', $last_ouput.chomp
7062
end
7163
end
7264

73-
# This tests both the railtie responsible for passing in the :compact style, and the compressor for honoring it
74-
test "compressor outputs compact style when specified in config" do
75-
command =<<END_OF_COMMAND
76-
puts Rails.application.config.assets.css_compressor.compress(<<CSS)
77-
div {
78-
color: red;
79-
}
80-
span {
81-
color: blue;
82-
}
83-
CSS
84-
END_OF_COMMAND
85-
within_rails_app "alternate_config_project" do
86-
runcmd "ruby script/rails runner '#{command}'", Dir.pwd, true, "Gemfile", {"RAILS_ENV" => "test"}
87-
assert_line_count 3
88-
end
89-
end
90-
91-
test "sprockets require works correctly" do
92-
css_output = sprockets_render("scss_project", "css_application.css")
65+
test 'sprockets require works correctly' do
66+
css_output = sprockets_render('scss_project', 'css_application.css')
9367
assert_match /globbed/, css_output
9468
end
9569

96-
test "sass imports work correctly" do
97-
css_output = sprockets_render("scss_project", "application.css.scss")
70+
test 'sass imports work correctly' do
71+
css_output = sprockets_render('scss_project', 'application.css.scss')
9872
assert_match /main/, css_output
9973
assert_match /top-level/, css_output
10074
assert_match /partial-sass/, css_output
@@ -109,8 +83,8 @@ class SassRailsTest < Sass::Rails::TestCase
10983
assert_match /without-css-ext/, css_output
11084
end
11185

112-
test "sass asset paths work" do
113-
css_output = sprockets_render("scss_project", "application.css.scss")
86+
test 'sass asset paths work' do
87+
css_output = sprockets_render('scss_project', 'application.css.scss')
11488
assert_match %r{asset-path:\s*"/assets/rails.png"}, css_output, 'asset-path:\s*"/assets/rails.png"'
11589
assert_match %r{asset-url:\s*url\(/assets/rails.png\)}, css_output, 'asset-url:\s*url\(/assets/rails.png\)'
11690
assert_match %r{image-path:\s*"/assets/rails.png"}, css_output, 'image-path:\s*"/assets/rails.png"'
@@ -130,15 +104,7 @@ class SassRailsTest < Sass::Rails::TestCase
130104
asset_data_url_regexp = %r{asset-data-url:\s*url\((.*?)\)}
131105
assert_match asset_data_url_regexp, css_output, 'asset-data-url:\s*url\((.*?)\)'
132106
asset_data_url_match = css_output.match(asset_data_url_regexp)[1]
133-
asset_data_url_expected = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw%2FeHBhY2tldCBiZWdpbj0i77u%2FIiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8%2BIDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb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OTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNS4xIE1hY2ludG9zaCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpCNzY5NDE1QkQ2NkMxMUUwOUUzM0E5Q0E2RTgyQUExQiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpCNzY5NDE1Q0Q2NkMxMUUwOUUzM0E5Q0E2RTgyQUExQiI%2BIDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkE3MzcyNTQ2RDY2QjExRTA5RTMzQTlDQTZFODJBQTFCIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkI3Njk0MTVBRDY2QzExRTA5RTMzQTlDQTZFODJBQTFCIi8%2BIDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY%2BIDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8%2B0HhJ9AAAABBJREFUeNpi%2BP%2F%2FPwNAgAEACPwC%2FtuiTRYAAAAASUVORK5CYII%3D'
134108
assert_equal asset_data_url_expected, asset_data_url_match
135109
end
136-
137-
test "css compressor compresses" do
138-
assert_equal "div{color:red}\n", Sass::Rails::CssCompressor.new.compress(<<CSS)
139-
div {
140-
color: red;
141-
}
142-
CSS
143-
end
144110
end

0 commit comments

Comments
 (0)