@@ -11,7 +11,7 @@ def setup
1111
1212 test ".compile_command" do
1313 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" )
1515 assert_kind_of ( Array , actual )
1616 assert_equal ( executable , actual . first )
1717 assert_includes ( actual , "-i" )
@@ -212,29 +212,25 @@ def setup
212212 end
213213 end
214214
215- test ".enhance_command when there are no engines" do
215+ test ".with_dynamic_input when there are no engines" do
216216 Dir . mktmpdir do |tmpdir |
217217 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
222219
223220 Rails . stub ( :root , root ) do
224221 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
227224 end
228225 end
229226 end
230227 end
231228 end
232229
233- test ".enhance_command when there are engines" do
230+ test ".with_dynamic_input when there are engines" do
234231 Dir . mktmpdir do |tmpdir |
235232 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
238234
239235 # Create necessary files
240236 FileUtils . mkdir_p ( File . dirname ( input_path ) )
@@ -245,24 +241,16 @@ def setup
245241 FileUtils . mkdir_p ( File . dirname ( engine_css_path ) )
246242 FileUtils . touch ( engine_css_path )
247243
248- command = [ "tailwindcss" , "-i" , input_path . to_s , "-o" , output_path . to_s ]
249-
250244 Rails . stub ( :root , root ) do
251245 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
261249 assert_match ( /tailwind\. css/ , temp_path . basename . to_s ) # should use temp file
262250 assert_includes [ Dir . tmpdir , '/tmp' ] , temp_path . dirname . to_s # should be in temp directory
263251
264252 # Check temp file contents
265- temp_content = File . read ( temp_path )
253+ temp_content = File . read ( actual )
266254 expected_content = <<~CSS
267255 @import "#{ engine_css_path } ";
268256 @import "#{ input_path } ";
0 commit comments