summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/runtime.rb5
-rw-r--r--spec/runtime/require_spec.rb25
2 files changed, 26 insertions, 4 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index b09a8814e5..d596c84815 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -83,11 +83,10 @@ module Bundler
begin
namespaced_file = dep.name.gsub('-', '/')
Kernel.require namespaced_file
- rescue LoadError
+ rescue LoadError => e
REGEXPS.find { |r| r =~ e.message }
regex_name = $1
- raise e if dep.autorequire || (regex_name && regex_name.gsub('-', '/') != namespaced_file)
- raise e if regex_name.nil?
+ raise if regex_name != namespaced_file
end
end
end
diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb
index e1c93897a5..5e5e9db22f 100644
--- a/spec/runtime/require_spec.rb
+++ b/spec/runtime/require_spec.rb
@@ -98,6 +98,28 @@ describe "Bundler.require" do
expect(err).to eq("ZOMG LOAD ERROR")
end
+ it "doesn't swallow the error when the library has an unrelated error" do
+ build_lib "loadfuuu", "1.0.0" do |s|
+ s.write "lib/loadfuuu.rb", "raise LoadError.new(\"cannot load such file -- load-bar\")"
+ end
+
+ gemfile <<-G
+ path "#{lib_path}"
+ gem "loadfuuu"
+ G
+
+ cmd = <<-RUBY
+ begin
+ Bundler.require
+ rescue LoadError => e
+ $stderr.puts "ZOMG LOAD ERROR: \#{e.message}"
+ end
+ RUBY
+ run(cmd, :expect_err => true)
+
+ expect(err).to eq("ZOMG LOAD ERROR: cannot load such file -- load-bar")
+ end
+
describe "with namespaced gems" do
before :each do
build_lib "jquery-rails", "1.0.0" do |s|
@@ -170,8 +192,9 @@ describe "Bundler.require" do
it "doesn't swallow the error when the library has an unrelated error" do
build_lib "load-fuuu", "1.0.0" do |s|
- s.write "lib/load-fuuu.rb", "raise LoadError.new(\"cannot load such file -- load-bar\")"
+ s.write "lib/load/fuuu.rb", "raise LoadError.new(\"cannot load such file -- load-bar\")"
end
+ lib_path('load-fuuu-1.0.0/lib/load-fuuu.rb').rmtree
gemfile <<-G
path "#{lib_path}"