@@ -281,7 +281,7 @@ def exec_name
281281 test "binstub when spring binary is missing" do
282282 begin
283283 File . rename ( app . path ( "bin/spring" ) , app . path ( "bin/spring.bak" ) )
284- assert_success "bin/rake -T" , stdout : "rake db:migrate "
284+ assert_failure "bin/rake -T" , stderr : "`load': cannot load such file "
285285 ensure
286286 File . rename ( app . path ( "bin/spring.bak" ) , app . path ( "bin/spring" ) )
287287 end
@@ -407,6 +407,65 @@ def exec_name
407407
408408 assert_success "bin/spring binstub rake" , stdout : "bin/rake: upgraded"
409409 assert_equal expected , app . path ( "bin/rake" ) . read
410+
411+ # newer variation which checks end of exception message using include
412+ File . write ( app . path ( "bin/rake" ) , <<-RUBY . strip_heredoc )
413+ #!/usr/bin/env ruby
414+ begin
415+ load File.expand_path('../spring', __FILE__)
416+ rescue LoadError => e
417+ raise unless e.message.include?('spring')
418+ end
419+ require 'bundler/setup'
420+ load Gem.bin_path('rake', 'rake')
421+ RUBY
422+
423+ assert_success "bin/spring binstub rake" , stdout : "bin/rake: upgraded"
424+ assert_equal expected , app . path ( "bin/rake" ) . read
425+ end
426+
427+ test "binstub remove with new binstub variations which checks end of the exception message using include" do
428+ # newer variation which checks end of exception message using include
429+ File . write ( app . path ( "bin/rake" ) , <<-RUBY . strip_heredoc )
430+ #!/usr/bin/env ruby
431+ begin
432+ load File.expand_path('../spring', __FILE__)
433+ rescue LoadError => e
434+ raise unless e.message.include?('spring')
435+ end
436+ require 'bundler/setup'
437+ load Gem.bin_path('rake', 'rake')
438+ RUBY
439+
440+ File . write ( app . path ( "bin/rails" ) , <<-RUBY . strip_heredoc )
441+ #!/usr/bin/env ruby
442+ begin
443+ load File.expand_path('../spring', __FILE__)
444+ rescue LoadError => e
445+ raise unless e.message.include?('spring')
446+ end
447+ APP_PATH = File.expand_path('../../config/application', __FILE__)
448+ require_relative '../config/boot'
449+ require 'rails/commands'
450+ RUBY
451+
452+ assert_success "bin/spring binstub --remove rake" , stdout : "bin/rake: Spring removed"
453+ assert_success "bin/spring binstub --remove rails" , stdout : "bin/rails: Spring removed"
454+
455+ expected = <<-RUBY . strip_heredoc
456+ #!/usr/bin/env ruby
457+ require 'bundler/setup'
458+ load Gem.bin_path('rake', 'rake')
459+ RUBY
460+ assert_equal expected , app . path ( "bin/rake" ) . read
461+
462+ expected = <<-RUBY . strip_heredoc
463+ #!/usr/bin/env ruby
464+ APP_PATH = File.expand_path('../../config/application', __FILE__)
465+ require_relative '../config/boot'
466+ require 'rails/commands'
467+ RUBY
468+ assert_equal expected , app . path ( "bin/rails" ) . read
410469 end
411470
412471 test "binstub remove with new binstub variations" do
0 commit comments