diff options
author | Hemant Kumar <hemant@codemancers.com> | 2013-07-18 00:31:18 -0700 |
---|---|---|
committer | Hemant Kumar <hemant@codemancers.com> | 2013-07-18 00:31:18 -0700 |
commit | d2678b1c6b0f1147c700088e735913fc02fff479 (patch) | |
tree | 0d3528d4467b54550de800654a2bcb32499cab7e | |
parent | b65fcc000681bcc102648b885770a9a7a90362ee (diff) | |
parent | 95d251ab40d7f7f35d636c7a87b63d028c8ff009 (diff) | |
download | bundler-d2678b1c6b0f1147c700088e735913fc02fff479.tar.gz |
Merge pull request #2538 from ndbroadbent/allow_require_true
Allow `require: true` as an alias for `require: <name>`
-rw-r--r-- | lib/bundler/runtime.rb | 2 | ||||
-rw-r--r-- | spec/runtime/require_spec.rb | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index 9dd6a5f4f0..e24540a8d0 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -68,6 +68,8 @@ module Bundler # dependency. If there are none, use the dependency's name # as the autorequire. Array(dep.autorequire || dep.name).each do |file| + # Allow `require: true` as an alias for `require: <name>` + file = dep.name if file == true required_file = file Kernel.require file end diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb index db72ff70f0..e1c93897a5 100644 --- a/spec/runtime/require_spec.rb +++ b/spec/runtime/require_spec.rb @@ -33,6 +33,10 @@ describe "Bundler.require" do s.write "lib/seven.rb", "puts 'seven'" end + build_lib "eight", "1.0.0" do |s| + s.write "lib/eight.rb", "puts 'eight'" + end + gemfile <<-G path "#{lib_path}" gem "one", :group => :bar, :require => %w(baz qux) @@ -42,6 +46,7 @@ describe "Bundler.require" do gem "five" gem "six", :group => "string" gem "seven", :group => :not + gem "eight", :require => true, :group => :require_true G end @@ -69,6 +74,10 @@ describe "Bundler.require" do # required in resolver order instead of gemfile order run("Bundler.require(:not)") expect(out.split("\n").sort).to eq(['seven', 'three']) + + # test require: true + run "Bundler.require(:require_true)" + expect(out).to eq("eight") end it "allows requiring gems with non standard names explicitly" do |