summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Broadbent <nathan.f77@gmail.com>2013-07-13 17:31:48 +1200
committerNathan Broadbent <nathan.f77@gmail.com>2013-07-13 17:36:36 +1200
commit95d251ab40d7f7f35d636c7a87b63d028c8ff009 (patch)
tree81c530d91997b5ab0ff86ebbe3e85cf55c71d3e5
parentea4ae196a3c519781802a050248c6929ef4229b4 (diff)
downloadbundler-95d251ab40d7f7f35d636c7a87b63d028c8ff009.tar.gz
Allow `require: true` as an alias for `require: <name>`
-rw-r--r--lib/bundler/runtime.rb2
-rw-r--r--spec/runtime/require_spec.rb9
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