summaryrefslogtreecommitdiff
path: root/spec/runtime/require_spec.rb
diff options
context:
space:
mode:
authorAdrien <adrien@siami.fr>2014-10-01 12:33:34 +0200
committerAdrien Siami <adrien.siami@dimelo.com>2014-10-02 10:04:12 +0200
commit7abc2846fed546d190ec0504d780cc75d52bcc66 (patch)
treec7571f12de1ec89f96d84bd49a6f43cfbec85bb7 /spec/runtime/require_spec.rb
parent9772abeac623245e6f6375c39663f35af428de3d (diff)
downloadbundler-7abc2846fed546d190ec0504d780cc75d52bcc66.tar.gz
Don't swallow LoadErrors when requiring a dashed gem
This looks like #1807 when raising a LoadError in a required gem, bundler will rescue it to try and see if it came from his own namespaced require or from the required file. If it comes from the dashed require it will re-raise the original exception in case the gem was dashed but the first require was ok but raised a LoadError after. However, the exception is swallowed if we require a dashed gem without the proper file name, for example gem name : 'foo-bar' and file architecture : 'foo/bar.rb' This PR raise the exception back in case it really comes from inside the namespaced file.
Diffstat (limited to 'spec/runtime/require_spec.rb')
-rw-r--r--spec/runtime/require_spec.rb25
1 files changed, 24 insertions, 1 deletions
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}"