@@ -11,7 +11,7 @@ def setup
11
11
12
12
test ".compile_command" do
13
13
Rails . stub ( :root , File ) do # Rails.root won't work in this test suite
14
- actual = Tailwindcss ::Commands . compile_command
14
+ actual = Tailwindcss ::Commands . compile_command ( "app/assets/tailwind/application.css" )
15
15
assert_kind_of ( Array , actual )
16
16
assert_equal ( executable , actual . first )
17
17
assert_includes ( actual , "-i" )
@@ -212,29 +212,25 @@ def setup
212
212
end
213
213
end
214
214
215
- test ".enhance_command when there are no engines" do
215
+ test ".with_dynamic_input when there are no engines" do
216
216
Dir . mktmpdir do |tmpdir |
217
217
root = Pathname . new ( tmpdir )
218
- input_path = root . join ( "app/assets/tailwind/application.css" )
219
- output_path = root . join ( "app/assets/builds/tailwind.css" )
220
-
221
- command = [ "tailwindcss" , "-i" , input_path . to_s , "-o" , output_path . to_s ]
218
+ input_path = root . join ( "app/assets/tailwind/application.css" ) . to_s
222
219
223
220
Rails . stub ( :root , root ) do
224
221
Tailwindcss ::Commands . stub ( :engines_tailwindcss_roots , [ ] ) do
225
- Tailwindcss ::Commands . enhance_command ( command ) do |actual |
226
- assert_equal command , actual
222
+ Tailwindcss ::Commands . with_dynamic_input do |actual |
223
+ assert_equal input_path , actual
227
224
end
228
225
end
229
226
end
230
227
end
231
228
end
232
229
233
- test ".enhance_command when there are engines" do
230
+ test ".with_dynamic_input when there are engines" do
234
231
Dir . mktmpdir do |tmpdir |
235
232
root = Pathname . new ( tmpdir )
236
- input_path = root . join ( "app/assets/tailwind/application.css" )
237
- output_path = root . join ( "app/assets/builds/tailwind.css" )
233
+ input_path = root . join ( "app/assets/tailwind/application.css" ) . to_s
238
234
239
235
# Create necessary files
240
236
FileUtils . mkdir_p ( File . dirname ( input_path ) )
@@ -245,24 +241,16 @@ def setup
245
241
FileUtils . mkdir_p ( File . dirname ( engine_css_path ) )
246
242
FileUtils . touch ( engine_css_path )
247
243
248
- command = [ "tailwindcss" , "-i" , input_path . to_s , "-o" , output_path . to_s ]
249
-
250
244
Rails . stub ( :root , root ) do
251
245
Tailwindcss ::Commands . stub ( :engines_tailwindcss_roots , [ engine_css_path . to_s ] ) do
252
- Tailwindcss ::Commands . enhance_command ( command ) do |actual |
253
- # Command should be modified to use a temporary file
254
- assert_equal command [ 0 ] , actual [ 0 ] # executable
255
- assert_equal command [ 1 ] , actual [ 1 ] # -i flag
256
- assert_equal command [ 3 ] , actual [ 3 ] # -o flag
257
- assert_equal command [ 4 ] , actual [ 4 ] # output path
258
-
259
- temp_path = Pathname . new ( actual [ 2 ] )
260
- refute_equal command [ 2 ] , temp_path . to_s # input path should be different
246
+ Tailwindcss ::Commands . with_dynamic_input do |actual |
247
+ temp_path = Pathname . new ( actual )
248
+ refute_equal input_path , temp_path . to_s # input path should be different
261
249
assert_match ( /tailwind\. css/ , temp_path . basename . to_s ) # should use temp file
262
250
assert_includes [ Dir . tmpdir , '/tmp' ] , temp_path . dirname . to_s # should be in temp directory
263
251
264
252
# Check temp file contents
265
- temp_content = File . read ( temp_path )
253
+ temp_content = File . read ( actual )
266
254
expected_content = <<~CSS
267
255
@import "#{ engine_css_path } ";
268
256
@import "#{ input_path } ";
0 commit comments