@@ -275,6 +275,13 @@ def exec_name
275275 end
276276
277277 test "binstub upgrade with new binstub variations" do
278+ expected = <<-RUBY . gsub ( /^ / , "" )
279+ #!/usr/bin/env ruby
280+ #{ Spring ::Client ::Binstub ::LOADER . strip }
281+ require 'bundler/setup'
282+ load Gem.bin_path('rake', 'rake')
283+ RUBY
284+
278285 # older variation with double quotes
279286 File . write ( app . path ( "bin/rake" ) , <<-RUBY . strip_heredoc )
280287 #!/usr/bin/env ruby
@@ -286,36 +293,38 @@ def exec_name
286293 load Gem.bin_path('rake', 'rake')
287294 RUBY
288295
296+ assert_success "bin/spring binstub rake" , stdout : "bin/rake: upgraded"
297+ assert_equal expected , app . path ( "bin/rake" ) . read
298+
289299 # newer variation with single quotes
290- File . write ( app . path ( "bin/rails " ) , <<-RUBY . strip_heredoc )
300+ File . write ( app . path ( "bin/rake " ) , <<-RUBY . strip_heredoc )
291301 #!/usr/bin/env ruby
292302 begin
293303 load File.expand_path('../spring', __FILE__)
294304 rescue LoadError
295305 end
296- APP_PATH = File.expand_path('../../config/application', __FILE__)
297- require_relative '../config/boot'
298- require 'rails/commands'
306+ require 'bundler/setup'
307+ load Gem.bin_path('rake', 'rake')
299308 RUBY
300309
301- assert_success "bin/spring binstub --all" , stdout : "upgraded"
310+ assert_success "bin/spring binstub rake" , stdout : "bin/rake: upgraded"
311+ assert_equal expected , app . path ( "bin/rake" ) . read
302312
303- expected = <<-RUBY . gsub ( /^ / , "" )
313+ # newer variation which checks end of exception message
314+ File . write ( app . path ( "bin/rake" ) , <<-RUBY . strip_heredoc )
304315 #!/usr/bin/env ruby
305- #{ Spring ::Client ::Binstub ::LOADER . strip }
316+ begin
317+ spring_bin_path = File.expand_path('../spring', __FILE__)
318+ load spring_bin_path
319+ rescue LoadError => e
320+ raise unless e.message.end_with? spring_bin_path, 'spring/binstub'
321+ end
306322 require 'bundler/setup'
307323 load Gem.bin_path('rake', 'rake')
308324 RUBY
309- assert_equal expected , app . path ( "bin/rake" ) . read
310325
311- expected = <<-RUBY . gsub ( /^ / , "" )
312- #!/usr/bin/env ruby
313- #{ Spring ::Client ::Binstub ::LOADER . strip }
314- APP_PATH = File.expand_path('../../config/application', __FILE__)
315- require_relative '../config/boot'
316- require 'rails/commands'
317- RUBY
318- assert_equal expected , app . path ( "bin/rails" ) . read
326+ assert_success "bin/spring binstub rake" , stdout : "bin/rake: upgraded"
327+ assert_equal expected , app . path ( "bin/rake" ) . read
319328 end
320329
321330 test "binstub remove with new binstub variations" do
0 commit comments