Skip to content

Commit a544854

Browse files
committed
Merge pull request #444 from felixbuenemann/dont-suppress-load-error
Don't supress non-spring load errors in binstub
2 parents c87e7f6 + 2238047 commit a544854

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/spring/client/binstub.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ class Binstub < Command
1313
# should cause the "unsprung" version of the command to run.
1414
LOADER = <<CODE
1515
begin
16-
load File.expand_path('../spring', __FILE__)
17-
rescue LoadError
16+
spring_bin_path = File.expand_path('../spring', __FILE__)
17+
load spring_bin_path
18+
rescue LoadError => e
19+
raise unless e.message.end_with? spring_bin_path, 'spring/binstub'
1820
end
1921
CODE
2022

lib/spring/test/acceptance_test.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,22 @@ def exec_name
208208
assert_success "bin/rake -T", stdout: "rake db:migrate"
209209
end
210210

211-
test "binstub when spring is uninstalled" do
211+
test "binstub when spring gem is missing" do
212212
without_gem "spring-#{Spring::VERSION}" do
213213
File.write(app.gemfile, app.gemfile.read.gsub(/gem 'spring.*/, ""))
214214
assert_success "bin/rake -T", stdout: "rake db:migrate"
215215
end
216216
end
217217

218+
test "binstub when spring binary is missing" do
219+
begin
220+
File.rename(app.path("bin/spring"), app.path("bin/spring.bak"))
221+
assert_success "bin/rake -T", stdout: "rake db:migrate"
222+
ensure
223+
File.rename(app.path("bin/spring.bak"), app.path("bin/spring"))
224+
end
225+
end
226+
218227
test "binstub upgrade" do
219228
File.write(app.path("bin/rake"), <<-RUBY.strip_heredoc)
220229
#!/usr/bin/env ruby

0 commit comments

Comments
 (0)