summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Wen <jrw2175@columbia.edu>2016-01-08 13:10:01 -0500
committerJames Wen <jrw2175@columbia.edu>2016-01-10 01:41:55 -0500
commit7205df2b5efbf909de426e60b1374b0f1032a353 (patch)
tree232420c30da9a5059f746cd153a9ea6dd6986a3b
parentba7314901e7f13b3849cf483460a683238948c40 (diff)
downloadbundler-7205df2b5efbf909de426e60b1374b0f1032a353.tar.gz
Add unit tests for `Bundler::SharedHelpers#in_bundle?`
-rw-r--r--spec/bundler/shared_helpers_spec.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb
index 81f78c8e21..56682400f6 100644
--- a/spec/bundler/shared_helpers_spec.rb
+++ b/spec/bundler/shared_helpers_spec.rb
@@ -72,6 +72,47 @@ describe Bundler::SharedHelpers do
end
end
end
+ describe "#in_bundle?" do
+ it "calls the find_gemfile method" do
+ expect(subject).to receive(:find_gemfile)
+ subject.in_bundle?
+ end
+ shared_examples_for "correctly determines whether to return a Gemfile path" do
+ context "currently in directory with a Gemfile" do
+ before do
+ File.new("Gemfile", "w")
+ end
+ it "returns path of the bundle gemfile" do
+ expect(subject.in_bundle?).to eq("#{bundled_app}/Gemfile")
+ end
+ end
+ context "currently in directory without a Gemfile" do
+ it "returns nil" do
+ expect(subject.in_bundle?).to eq(nil)
+ end
+ end
+ end
+ context "ENV['BUNDLE_GEMFILE'] set" do
+ before do
+ ENV["BUNDLE_GEMFILE"] = "/path/Gemfile"
+ end
+ it "returns ENV['BUNDLE_GEMFILE']" do
+ expect(subject.in_bundle?).to eq("/path/Gemfile")
+ end
+ end
+ context "ENV['BUNDLE_GEMFILE'] not set" do
+ before do
+ ENV["BUNDLE_GEMFILE"] = nil
+ end
+ it_behaves_like "correctly determines whether to return a Gemfile path"
+ end
+ context "ENV['BUNDLE_GEMFILE'] is blank" do
+ before do
+ ENV["BUNDLE_GEMFILE"] = ""
+ end
+ it_behaves_like "correctly determines whether to return a Gemfile path"
+ end
+ end
describe "#set_bundle_environment" do
shared_examples_for "ENV['PATH'] gets set correctly" do
before do