diff options
author | Terence Lee <hone02@gmail.com> | 2012-08-14 01:08:54 -0500 |
---|---|---|
committer | Terence Lee <hone02@gmail.com> | 2012-08-14 01:08:58 -0500 |
commit | 67c6fcba6f97b0a870ae62325b28eb89c9c2ad6c (patch) | |
tree | bd7948fd7d5c6a50558d39bd46de2931f8997155 | |
parent | 3a1121a568f8b6785429291a080de2fa6188c520 (diff) | |
download | bundler-67c6fcba6f97b0a870ae62325b28eb89c9c2ad6c.tar.gz |
namespace gem require logic handles case where regex fails
-rw-r--r-- | lib/bundler/runtime.rb | 2 | ||||
-rw-r--r-- | spec/runtime/require_spec.rb | 25 |
2 files changed, 25 insertions, 2 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index 5f6e82eeac..0f71e9e482 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -74,7 +74,7 @@ module Bundler Kernel.require namespaced_file rescue LoadError REGEXPS.find { |r| r =~ e.message } - raise if dep.autorequire || $1.gsub('-', '/') != namespaced_file + raise if dep.autorequire || ($1 && $1.gsub('-', '/') != namespaced_file) || $1.nil? end else REGEXPS.find { |r| r =~ e.message } diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb index fdd0a4248c..2f2c73f899 100644 --- a/spec/runtime/require_spec.rb +++ b/spec/runtime/require_spec.rb @@ -107,7 +107,7 @@ describe "Bundler.require" do out.should eq("jquery/rails") end - it "does not mangle explictly given requires" do + it "handles the case where the regex fails" do gemfile <<-G path "#{lib_path}" gem 'jquery-rails', :require => 'jquery-rails' @@ -118,6 +118,29 @@ describe "Bundler.require" do R err.should == "ZOMG LOAD ERROR" end + + it "doesn't obscure actual error messages" do + build_lib "load-fuuu", "1.0.0" do |s| + s.write "lib/load-fuuu.rb", "require 'load/fuuu'" + s.write "lib/load/fuuu.rb", "raise LoadError.new(\"Could not open library 'libfuuu-1.0': libfuuu-1.0: cannot open shared object file: No such file or directory.\")" + end + + gemfile <<-G + path "#{lib_path}" + gem "load-fuuu" + G + + cmd = <<-RUBY + begin + Bundler.require + rescue LoadError => e + $stderr.puts "ZOMG LOAD ERROR" if e.message.include?("Could not open library 'libfuuu-1.0'") + end + RUBY + run(cmd, :expect_err => true) + + err.should == "ZOMG LOAD ERROR" + end end describe "using bundle exec" do |