Skip to content

Commit 2238047

Browse files
Don't supress non-spring load errors in binstub
Without this change, the spring binstub supresses unrelated load errors, eg. due to errors in initializers or loaded gems. This change causes the binstub to only ignore a missing spring binary or gem. This closes #370 and resolves #259.
1 parent c87e7f6 commit 2238047

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/spring/client/binstub.rb

Lines changed: 4 additions & 2 deletions
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

Lines changed: 10 additions & 1 deletion
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)