@@ -275,6 +275,13 @@ def exec_name
275
275
end
276
276
277
277
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
+
278
285
# older variation with double quotes
279
286
File . write ( app . path ( "bin/rake" ) , <<-RUBY . strip_heredoc )
280
287
#!/usr/bin/env ruby
@@ -286,36 +293,38 @@ def exec_name
286
293
load Gem.bin_path('rake', 'rake')
287
294
RUBY
288
295
296
+ assert_success "bin/spring binstub rake" , stdout : "bin/rake: upgraded"
297
+ assert_equal expected , app . path ( "bin/rake" ) . read
298
+
289
299
# 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 )
291
301
#!/usr/bin/env ruby
292
302
begin
293
303
load File.expand_path('../spring', __FILE__)
294
304
rescue LoadError
295
305
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')
299
308
RUBY
300
309
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
302
312
303
- expected = <<-RUBY . gsub ( /^ / , "" )
313
+ # newer variation which checks end of exception message
314
+ File . write ( app . path ( "bin/rake" ) , <<-RUBY . strip_heredoc )
304
315
#!/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
306
322
require 'bundler/setup'
307
323
load Gem.bin_path('rake', 'rake')
308
324
RUBY
309
- assert_equal expected , app . path ( "bin/rake" ) . read
310
325
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
319
328
end
320
329
321
330
test "binstub remove with new binstub variations" do
0 commit comments