diff options
author | Andre Arko <andre@arko.net> | 2011-11-30 12:59:51 -1000 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2011-11-30 13:00:01 -1000 |
commit | 96366953fc76e5850d73fb19f2b7ac7936bb0532 (patch) | |
tree | 56421201f191eb525f02b0bf5123c36982ed564b | |
parent | af400195ddd6866b6188ed29a87efc105522c740 (diff) | |
download | bundler-96366953fc76e5850d73fb19f2b7ac7936bb0532.tar.gz |
only auto-namespace requires for implied requires
fixes #1531
-rw-r--r-- | lib/bundler/runtime.rb | 5 | ||||
-rw-r--r-- | spec/runtime/require_spec.rb | 31 |
2 files changed, 33 insertions, 3 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index efa4507d6c..3b453d0c9f 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -68,9 +68,7 @@ module Bundler Kernel.require file end rescue LoadError => e - REGEXPS.find { |r| r =~ e.message } - - if dep.name.include?('-') + if dep.autorequire.nil? && dep.name.include?('-') begin namespaced_file = dep.name.gsub('-', '/') Kernel.require namespaced_file @@ -79,6 +77,7 @@ module Bundler raise if dep.autorequire || $1.gsub('-', '/') != namespaced_file end else + REGEXPS.find { |r| r =~ e.message } raise if dep.autorequire || $1 != required_file end end diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb index bad1ec9730..fdd0a4248c 100644 --- a/spec/runtime/require_spec.rb +++ b/spec/runtime/require_spec.rb @@ -89,6 +89,37 @@ describe "Bundler.require" do err.should == "ZOMG LOAD ERROR" end + describe "with namespaced gems" do + before :each do + build_lib "jquery-rails", "1.0.0" do |s| + s.write "lib/jquery/rails.rb", "puts 'jquery/rails'" + end + lib_path('jquery-rails-1.0.0/lib/jquery-rails.rb').rmtree + end + + it "requires gem names that are namespaced" do + gemfile <<-G + path '#{lib_path}' + gem 'jquery-rails' + G + + run "Bundler.require" + out.should eq("jquery/rails") + end + + it "does not mangle explictly given requires" do + gemfile <<-G + path "#{lib_path}" + gem 'jquery-rails', :require => 'jquery-rails' + G + + load_error_run <<-R, 'jquery-rails' + Bundler.require + R + err.should == "ZOMG LOAD ERROR" + end + end + describe "using bundle exec" do it "requires the locked gems" do bundle "exec ruby -e 'Bundler.require'" |