sassc4-rails 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +37 -0
- data/CODE_OF_CONDUCT.md +10 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +124 -0
- data/Rakefile +33 -0
- data/gemfiles/rails_4_2.gemfile +6 -0
- data/gemfiles/rails_5_2.gemfile +6 -0
- data/gemfiles/rails_6_0.gemfile +6 -0
- data/gemfiles/sprockets-rails_2_3.gemfile +6 -0
- data/gemfiles/sprockets-rails_3_0.gemfile +6 -0
- data/gemfiles/sprockets_3_0.gemfile +6 -0
- data/gemfiles/sprockets_4_0.gemfile +6 -0
- data/lib/rails/generators/sass/assets/assets_generator.rb +13 -0
- data/lib/rails/generators/sass/assets/templates/stylesheet.sass +3 -0
- data/lib/rails/generators/sass/scaffold/scaffold_generator.rb +9 -0
- data/lib/rails/generators/sass_scaffold.rb +15 -0
- data/lib/rails/generators/scss/assets/assets_generator.rb +13 -0
- data/lib/rails/generators/scss/assets/templates/stylesheet.scss +3 -0
- data/lib/rails/generators/scss/scaffold/scaffold_generator.rb +10 -0
- data/lib/sassc/rails/compressor.rb +34 -0
- data/lib/sassc/rails/functions.rb +13 -0
- data/lib/sassc/rails/importer.rb +181 -0
- data/lib/sassc/rails/railtie.rb +81 -0
- data/lib/sassc/rails/template.rb +113 -0
- data/lib/sassc/rails/version.rb +7 -0
- data/lib/sassc/rails.rb +10 -0
- data/lib/sassc-rails.rb +4 -0
- data/sassc-rails.gemspec +32 -0
- data/test/dummy/app/assets/config/manifest.js +3 -0
- data/test/dummy/app/assets/fonts/fake-font.ttf +0 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/images/1x1.png +0 -0
- data/test/dummy/app/assets/images/rails.png +0 -0
- data/test/dummy/app/assets/stylesheets/_top_level_partial.scss +3 -0
- data/test/dummy/app/assets/stylesheets/application.scss +5 -0
- data/test/dummy/app/assets/stylesheets/css_application.css +11 -0
- data/test/dummy/app/assets/stylesheets/css_erb_handler.css.erb +3 -0
- data/test/dummy/app/assets/stylesheets/css_sass_erb_handler.sass.erb +2 -0
- data/test/dummy/app/assets/stylesheets/css_sass_handler.css.sass +2 -0
- data/test/dummy/app/assets/stylesheets/css_scss_erb_handler.scss.erb +3 -0
- data/test/dummy/app/assets/stylesheets/css_scss_handler.css.scss +3 -0
- data/test/dummy/app/assets/stylesheets/erb_render_with_context.css.erb +1804 -0
- data/test/dummy/app/assets/stylesheets/glob_multiple_extensions_test.scss +1 -0
- data/test/dummy/app/assets/stylesheets/glob_test.scss +1 -0
- data/test/dummy/app/assets/stylesheets/globbed/globbed.scss +3 -0
- data/test/dummy/app/assets/stylesheets/globbed/nested/nested_glob.scss +3 -0
- data/test/dummy/app/assets/stylesheets/globbed_multiple_extensions/glob.scss.erb +3 -0
- data/test/dummy/app/assets/stylesheets/helpers_test.scss +18 -0
- data/test/dummy/app/assets/stylesheets/imports_test.scss +23 -0
- data/test/dummy/app/assets/stylesheets/in_load_paths/partial_in_load_paths.scss +3 -0
- data/test/dummy/app/assets/stylesheets/partials/_css_sass_import.sass +5 -0
- data/test/dummy/app/assets/stylesheets/partials/_explicit_extension_import.foo +3 -0
- data/test/dummy/app/assets/stylesheets/partials/_sass_import.sass +2 -0
- data/test/dummy/app/assets/stylesheets/partials/_scss_import.scss +9 -0
- data/test/dummy/app/assets/stylesheets/partials/_without_css_ext.scss +3 -0
- data/test/dummy/app/assets/stylesheets/partials/subfolder/_relative_sass.sass +2 -0
- data/test/dummy/app/assets/stylesheets/partials/subfolder/_relative_scss.scss +3 -0
- data/test/dummy/app/assets/stylesheets/partials/subfolder/relative_not_a_partial.scss +3 -0
- data/test/dummy/app/assets/stylesheets/sass_erb_handler.sass.erb +2 -0
- data/test/dummy/app/assets/stylesheets/scss_erb_handler.scss.erb +3 -0
- data/test/dummy/app/assets/stylesheets/special_characters.scss +5 -0
- data/test/dummy/app/assets/stylesheets/subfolder/_defaults.scss +3 -0
- data/test/dummy/app/assets/stylesheets/subfolder/another_plain.css +3 -0
- data/test/dummy/app/assets/stylesheets/subfolder/plain.css +3 -0
- data/test/dummy/app/assets/stylesheets/subfolder/second_level.scss +2 -0
- data/test/dummy/app/assets/stylesheets/syntax_error.scss +3 -0
- data/test/sassc_rails_test.rb +334 -0
- data/test/test_helper.rb +17 -0
- metadata +281 -0
@@ -0,0 +1 @@
|
|
1
|
+
@import "globbed_multiple_extensions/**/*";
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "globbed/**/*";
|
@@ -0,0 +1,18 @@
|
|
1
|
+
.rails {
|
2
|
+
asset-path: asset-path("rails.png");
|
3
|
+
asset-url: asset-url("rails.png");
|
4
|
+
image-path: image-path("rails.png");
|
5
|
+
image-url: image-url("rails.png");
|
6
|
+
video-path: video-path("rails.mp4");
|
7
|
+
video-url: video-url("rails.mp4");
|
8
|
+
audio-path: audio-path("rails.mp3");
|
9
|
+
audio-url: audio-url("rails.mp3");
|
10
|
+
font-path: font-path("rails.ttf");
|
11
|
+
font-url: font-url("rails.ttf");
|
12
|
+
font-url-with-query-hash: font-url("rails.ttf?#iefix");
|
13
|
+
javascript-path: javascript-path("rails.js");
|
14
|
+
javascript-url: javascript-url("rails.js");
|
15
|
+
stylesheet-path: stylesheet-path("rails.css");
|
16
|
+
stylesheet-url: stylesheet-url("rails.css");
|
17
|
+
asset-data-url: asset-data-url("1x1.png");
|
18
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
@import "partials/css_sass_import";
|
2
|
+
@import "partials/sass_import";
|
3
|
+
@import "partials/scss_import";
|
4
|
+
@import "partials/explicit_extension_import.foo";
|
5
|
+
@import "globbed/**/*";
|
6
|
+
@import "subfolder/plain";
|
7
|
+
@import "subfolder/second_level";
|
8
|
+
@import "partials/without_css_ext";
|
9
|
+
@import "css_erb_handler";
|
10
|
+
@import "scss_erb_handler";
|
11
|
+
@import "sass_erb_handler";
|
12
|
+
@import "css_scss_handler";
|
13
|
+
@import "css_sass_handler";
|
14
|
+
@import "css_scss_erb_handler";
|
15
|
+
@import "css_sass_erb_handler";
|
16
|
+
@import 'partial_in_load_paths';
|
17
|
+
|
18
|
+
.main {
|
19
|
+
color: yellow;
|
20
|
+
@include background-from-partial(red);
|
21
|
+
}
|
22
|
+
|
23
|
+
@include without-css-ext;
|
@@ -0,0 +1,334 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class SassRailsTest < MiniTest::Test
|
6
|
+
attr_reader :app
|
7
|
+
|
8
|
+
def setup
|
9
|
+
Rails.application = nil
|
10
|
+
|
11
|
+
@app = Class.new(Rails::Application)
|
12
|
+
@app.config.active_support.deprecation = :log
|
13
|
+
@app.config.eager_load = false
|
14
|
+
@app.config.root = File.join(File.dirname(__FILE__), "dummy")
|
15
|
+
@app.config.log_level = :debug
|
16
|
+
|
17
|
+
# reset config back to default
|
18
|
+
@app.config.assets.delete(:css_compressor)
|
19
|
+
@app.config.sass = ActiveSupport::OrderedOptions.new
|
20
|
+
@app.config.sass.preferred_syntax = :scss
|
21
|
+
@app.config.sass.load_paths = []
|
22
|
+
|
23
|
+
# Not actually a default, but it makes assertions more complicated
|
24
|
+
@app.config.sass.line_comments = false
|
25
|
+
|
26
|
+
# Add a fake compressor for testing purposes
|
27
|
+
Sprockets.register_compressor "text/css", :test, TestCompressor
|
28
|
+
|
29
|
+
Rails.backtrace_cleaner.remove_silencers!
|
30
|
+
end
|
31
|
+
|
32
|
+
def teardown
|
33
|
+
directory = "#{Rails.root}/tmp"
|
34
|
+
FileUtils.remove_dir(directory) if File.directory?(directory)
|
35
|
+
end
|
36
|
+
|
37
|
+
def render_asset(asset)
|
38
|
+
app.assets[asset].to_s
|
39
|
+
end
|
40
|
+
|
41
|
+
def initialize!
|
42
|
+
Rails.env = "test"
|
43
|
+
@app.initialize!
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize_dev!
|
47
|
+
Rails.env = "development"
|
48
|
+
@app.initialize!
|
49
|
+
end
|
50
|
+
|
51
|
+
def initialize_prod!
|
52
|
+
Rails.env = "production"
|
53
|
+
@app.initialize!
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_setup_works
|
57
|
+
initialize_dev!
|
58
|
+
|
59
|
+
asset = render_asset("application.css")
|
60
|
+
|
61
|
+
assert_equal <<-CSS, asset
|
62
|
+
.hello {
|
63
|
+
color: #FFF;
|
64
|
+
}
|
65
|
+
CSS
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_raises_sassc_syntax_error
|
69
|
+
initialize!
|
70
|
+
|
71
|
+
assert_raises(SassC::SyntaxError) do
|
72
|
+
render_asset("syntax_error.css")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_all_sass_asset_paths_work
|
77
|
+
skip
|
78
|
+
|
79
|
+
initialize!
|
80
|
+
|
81
|
+
css_output = render_asset("helpers_test.css")
|
82
|
+
|
83
|
+
assert_match %r{asset-path:\s*"/assets/rails.png"}, css_output, 'asset-path:\s*"/assets/rails.png"'
|
84
|
+
assert_match %r{asset-url:\s*url\(/assets/rails.png\)}, css_output, 'asset-url:\s*url\(/assets/rails.png\)'
|
85
|
+
assert_match %r{image-path:\s*"/assets/rails.png"}, css_output, 'image-path:\s*"/assets/rails.png"'
|
86
|
+
assert_match %r{image-url:\s*url\(/assets/rails.png\)}, css_output, 'image-url:\s*url\(/assets/rails.png\)'
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_sass_asset_paths_work
|
90
|
+
initialize!
|
91
|
+
|
92
|
+
css_output = render_asset("helpers_test.css")
|
93
|
+
|
94
|
+
assert_match %r{video-path:\s*"/videos/rails.mp4"}, css_output, 'video-path:\s*"/videos/rails.mp4"'
|
95
|
+
assert_match %r{video-url:\s*url\(/videos/rails.mp4\)}, css_output, 'video-url:\s*url\(/videos/rails.mp4\)'
|
96
|
+
assert_match %r{audio-path:\s*"/audios/rails.mp3"}, css_output, 'audio-path:\s*"/audios/rails.mp3"'
|
97
|
+
assert_match %r{audio-url:\s*url\(/audios/rails.mp3\)}, css_output, 'audio-url:\s*url\(/audios/rails.mp3\)'
|
98
|
+
assert_match %r{font-path:\s*"/fonts/rails.ttf"}, css_output, 'font-path:\s*"/fonts/rails.ttf"'
|
99
|
+
assert_match %r{font-url:\s*url\(/fonts/rails.ttf\)}, css_output, 'font-url:\s*url\(/fonts/rails.ttf\)'
|
100
|
+
assert_match %r{font-url-with-query-hash:\s*url\(/fonts/rails.ttf\?#iefix\)}, css_output, 'font-url:\s*url\(/fonts/rails.ttf?#iefix\)'
|
101
|
+
assert_match %r{javascript-path:\s*"/javascripts/rails.js"}, css_output, 'javascript-path:\s*"/javascripts/rails.js"'
|
102
|
+
assert_match %r{javascript-url:\s*url\(/javascripts/rails.js\)}, css_output, 'javascript-url:\s*url\(/javascripts/rails.js\)'
|
103
|
+
assert_match %r{stylesheet-path:\s*"/stylesheets/rails.css"}, css_output, 'stylesheet-path:\s*"/stylesheets/rails.css"'
|
104
|
+
assert_match %r{stylesheet-url:\s*url\(/stylesheets/rails.css\)}, css_output, 'stylesheet-url:\s*url\(/stylesheets/rails.css\)'
|
105
|
+
|
106
|
+
asset_data_url_regexp = %r{asset-data-url:\s*url\((.*?)\)}
|
107
|
+
assert_match asset_data_url_regexp, css_output, 'asset-data-url:\s*url\((.*?)\)'
|
108
|
+
asset_data_url_match = css_output.match(asset_data_url_regexp)[1]
|
109
|
+
asset_data_url_expected = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw%" +
|
110
|
+
"2FeHBhY2tldCBiZWdpbj0i77u%2FIiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8%2BIDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjA" +
|
111
|
+
"xMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRw" +
|
112
|
+
"Oi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDc" +
|
113
|
+
"mVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNS4xIE1hY2ludG9zaCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpCNzY5NDE1QkQ2NkMxMUUwOUUzM0E5Q0E2RTgyQUExQiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpCNzY5NDE1Q0" +
|
114
|
+
"Q2NkMxMUUwOUUzM0E5Q0E2RTgyQUExQiI%2BIDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkE3MzcyNTQ2RDY2QjExRTA5RTMzQTlDQTZFODJBQTFCIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkI3Njk0M" +
|
115
|
+
"TVBRDY2QzExRTA5RTMzQTlDQTZFODJBQTFCIi8%2BIDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY%2BIDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8%2B0HhJ9AAAABBJREFUeNpi%2BP%2F%2FPwNAgAEACPwC%2FtuiTRYAAAAA" +
|
116
|
+
"SUVORK5CYII%3D"
|
117
|
+
assert_equal asset_data_url_expected, asset_data_url_match
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_sass_imports_work_correctly
|
121
|
+
app.config.sass.load_paths << Rails.root.join('app/assets/stylesheets/in_load_paths')
|
122
|
+
initialize!
|
123
|
+
|
124
|
+
css_output = render_asset("imports_test.css")
|
125
|
+
assert_match /main/, css_output
|
126
|
+
assert_match /top-level/, css_output
|
127
|
+
assert_match /partial-sass/, css_output
|
128
|
+
assert_match /partial-scss/, css_output
|
129
|
+
assert_match /partial-foo/, css_output
|
130
|
+
assert_match /sub-folder-relative-sass/, css_output
|
131
|
+
assert_match /sub-folder-relative-scss/, css_output
|
132
|
+
assert_match /not-a-partial/, css_output
|
133
|
+
assert_match /plain-old-css/, css_output
|
134
|
+
assert_match /another-plain-old-css/, css_output
|
135
|
+
assert_match /without-css-ext/, css_output
|
136
|
+
assert_match /css-scss-handler/, css_output
|
137
|
+
assert_match /css-sass-handler/, css_output
|
138
|
+
assert_match /css-erb-handler/, css_output
|
139
|
+
assert_match /scss-erb-handler/, css_output
|
140
|
+
assert_match /sass-erb-handler/, css_output
|
141
|
+
|
142
|
+
# do these two actually test anything?
|
143
|
+
# should the extension be changed?
|
144
|
+
assert_match /css-sass-erb-handler/, css_output
|
145
|
+
assert_match /css-scss-erb-handler/, css_output
|
146
|
+
|
147
|
+
assert_match /default-old-css/, css_output
|
148
|
+
|
149
|
+
assert_match /globbed/, css_output
|
150
|
+
assert_match /nested-glob/, css_output
|
151
|
+
|
152
|
+
assert_match /partial_in_load_paths/, css_output
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_style_config_item_is_defaulted_to_expanded_in_development_mode
|
156
|
+
initialize_dev!
|
157
|
+
assert_equal :expanded, Rails.application.config.sass.style
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_style_config_item_is_honored
|
161
|
+
@app.config.sass.style = :nested
|
162
|
+
initialize!
|
163
|
+
assert_equal :nested, Rails.application.config.sass.style
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_line_comments_active_in_dev
|
167
|
+
@app.config.sass.line_comments = true
|
168
|
+
initialize_dev!
|
169
|
+
|
170
|
+
css_output = render_asset("css_scss_handler.css")
|
171
|
+
assert_match %r{/* line 1}, css_output
|
172
|
+
assert_match %r{.+test/dummy/app/assets/stylesheets/css_scss_handler.css.scss}, css_output
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_context_is_being_passed_to_erb_render
|
176
|
+
initialize!
|
177
|
+
|
178
|
+
css_output = render_asset("erb_render_with_context.css.erb")
|
179
|
+
assert_match /@font-face/, css_output
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_special_characters_compile
|
183
|
+
initialize!
|
184
|
+
css_output = render_asset("special_characters.css")
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_css_compressor_config_item_is_honored_if_not_development_mode
|
188
|
+
@app.config.assets.css_compressor = :test
|
189
|
+
initialize_prod!
|
190
|
+
assert_equal :test, Rails.application.config.assets.css_compressor
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_css_compressor_config_item_may_be_nil_in_test_mode
|
194
|
+
@app.config.assets.css_compressor = nil
|
195
|
+
initialize!
|
196
|
+
assert_nil Rails.application.config.assets.css_compressor
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_css_compressor_is_defined_in_test_mode
|
200
|
+
initialize!
|
201
|
+
assert_equal :sass, Rails.application.config.assets.css_compressor
|
202
|
+
end
|
203
|
+
|
204
|
+
def test_css_compressor_is_defined_in_prod_mode
|
205
|
+
initialize_prod!
|
206
|
+
assert_equal :sass, Rails.application.config.assets.css_compressor
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_compression_works
|
210
|
+
initialize_prod!
|
211
|
+
|
212
|
+
asset = render_asset("application.css")
|
213
|
+
assert_equal <<-CSS, asset
|
214
|
+
.hello{color:#FFF}
|
215
|
+
CSS
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_compression_works
|
219
|
+
initialize_prod!
|
220
|
+
|
221
|
+
asset = render_asset("application.css")
|
222
|
+
assert_equal <<-CSS, asset
|
223
|
+
.hello{color:#FFF}
|
224
|
+
CSS
|
225
|
+
end
|
226
|
+
|
227
|
+
def test_sassc_compression_is_used
|
228
|
+
engine = stub(render: "")
|
229
|
+
SassC::Engine.expects(:new).returns(engine)
|
230
|
+
SassC::Engine.expects(:new).with("", {style: :compressed}).returns(engine)
|
231
|
+
|
232
|
+
initialize_prod!
|
233
|
+
|
234
|
+
render_asset("application.css")
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_allows_for_inclusion_of_inline_source_maps
|
238
|
+
@app.config.sass.inline_source_maps = true
|
239
|
+
initialize_dev!
|
240
|
+
|
241
|
+
asset = render_asset("application.css")
|
242
|
+
assert_match /.hello/, asset
|
243
|
+
assert_match /sourceMappingURL/, asset
|
244
|
+
end
|
245
|
+
|
246
|
+
#test 'sprockets require works correctly' do
|
247
|
+
# skip
|
248
|
+
|
249
|
+
# within_rails_app('scss_project') do |app_root|
|
250
|
+
# css_output = asset_output('css_application.css')
|
251
|
+
# assert_match /globbed/, css_output
|
252
|
+
|
253
|
+
# if File.exist?("#{app_root}/log/development.log")
|
254
|
+
# log_file = "#{app_root}/log/development.log"
|
255
|
+
# elsif File.exist?("#{app_root}/log/test.log")
|
256
|
+
# log_file = "#{app_root}/log/test.log"
|
257
|
+
# else
|
258
|
+
# flunk "log file was not created"
|
259
|
+
# end
|
260
|
+
|
261
|
+
# log_output = File.open(log_file).read
|
262
|
+
# refute_match /Warning/, log_output
|
263
|
+
# end
|
264
|
+
#end
|
265
|
+
|
266
|
+
#test 'sprockets directives are ignored within an import' do
|
267
|
+
# skip
|
268
|
+
|
269
|
+
# css_output = sprockets_render('scss_project', 'import_css_application.css')
|
270
|
+
# assert_match /\.css-application/, css_output
|
271
|
+
# assert_match /\.import-css-application/, css_output
|
272
|
+
#end
|
273
|
+
|
274
|
+
def test_globbed_imports_work_with_multiple_extensions
|
275
|
+
initialize!
|
276
|
+
|
277
|
+
asset = render_asset("glob_multiple_extensions_test.css")
|
278
|
+
|
279
|
+
assert_equal <<-CSS, asset
|
280
|
+
.glob{margin:0}
|
281
|
+
CSS
|
282
|
+
end
|
283
|
+
|
284
|
+
def test_globbed_imports_work_when_globbed_file_is_changed
|
285
|
+
skip "This seems to work in practice, possible test setup problem"
|
286
|
+
|
287
|
+
begin
|
288
|
+
initialize!
|
289
|
+
|
290
|
+
new_file = File.join(File.dirname(__FILE__), 'dummy', 'app', 'assets', 'stylesheets', 'globbed', 'new_glob.scss')
|
291
|
+
|
292
|
+
File.open(new_file, 'w') do |file|
|
293
|
+
file.puts '.new-file-test { color: #000; }'
|
294
|
+
end
|
295
|
+
|
296
|
+
css_output = render_asset("glob_test.css")
|
297
|
+
assert_match /new-file-test/, css_output
|
298
|
+
|
299
|
+
File.open(new_file, 'w') do |file|
|
300
|
+
file.puts '.changed-file-test { color: #000; }'
|
301
|
+
end
|
302
|
+
|
303
|
+
new_css_output = render_asset("glob_test.css")
|
304
|
+
assert_match /changed-file-test/, new_css_output
|
305
|
+
refute_equal css_output, new_css_output
|
306
|
+
ensure
|
307
|
+
File.delete(new_file)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
def test_globbed_imports_work_when_globbed_file_is_added
|
312
|
+
begin
|
313
|
+
initialize!
|
314
|
+
|
315
|
+
css_output = render_asset("glob_test.css")
|
316
|
+
refute_match /changed-file-test/, css_output
|
317
|
+
new_file = File.join(File.dirname(__FILE__), 'dummy', 'app', 'assets', 'stylesheets', 'globbed', 'new_glob.scss')
|
318
|
+
|
319
|
+
File.open(new_file, 'w') do |file|
|
320
|
+
file.puts '.changed-file-test { color: #000; }'
|
321
|
+
end
|
322
|
+
|
323
|
+
new_css_output = render_asset("glob_test.css")
|
324
|
+
assert_match /changed-file-test/, new_css_output
|
325
|
+
refute_equal css_output, new_css_output
|
326
|
+
ensure
|
327
|
+
File.delete(new_file)
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
class TestCompressor
|
332
|
+
def self.call(*); end
|
333
|
+
end
|
334
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
ENV["RAILS_ENV"] = "test"
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
+
|
8
|
+
require "pry"
|
9
|
+
require "fileutils"
|
10
|
+
require 'rails'
|
11
|
+
require 'bundler/setup'
|
12
|
+
require "minitest/autorun"
|
13
|
+
require 'mocha/minitest'
|
14
|
+
|
15
|
+
Bundler.require
|
16
|
+
|
17
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|