summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Espinosa <glennpeter.espinosa@gmail.com>2017-06-25 10:47:18 -0400
committerGlenn Espinosa <glennpeter.espinosa@gmail.com>2017-06-25 12:20:45 -0400
commita779cf00476acd535c6b7a71467fdbd09e4f6d50 (patch)
tree7449779cad825324f1037523143bb789603ff566
parentb6c3d273ab868bb091ca181ae2f0f73cd61e5331 (diff)
downloadbundler-a779cf00476acd535c6b7a71467fdbd09e4f6d50.tar.gz
Move expand_path to #default_gemfile and add integration spec
-rw-r--r--lib/bundler/shared_helpers.rb4
-rw-r--r--spec/bundler/shared_helpers_spec.rb18
-rw-r--r--spec/runtime/setup_spec.rb54
3 files changed, 54 insertions, 22 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index bdc2aad113..01433a2096 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -28,7 +28,7 @@ module Bundler
def default_gemfile
gemfile = find_gemfile(:order_matters)
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
- Pathname.new(gemfile).untaint
+ Pathname.new(gemfile).untaint.expand_path
end
def default_lockfile
@@ -191,7 +191,7 @@ module Bundler
def find_gemfile(order_matters = false)
given = ENV["BUNDLE_GEMFILE"]
- return File.expand_path(given) if given && !given.empty?
+ return given if given && !given.empty?
names = gemfile_names
names.reverse! if order_matters && Bundler.feature_flag.prefer_gems_rb?
find_file(*names)
diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb
index 880724180f..c17f3b8582 100644
--- a/spec/bundler/shared_helpers_spec.rb
+++ b/spec/bundler/shared_helpers_spec.rb
@@ -30,6 +30,16 @@ RSpec.describe Bundler::SharedHelpers do
)
end
end
+
+ context "Gemfile is not an absolute path" do
+ before { ENV["BUNDLE_GEMFILE"] = "Gemfile" }
+
+ let(:expected_gemfile_path) { Pathname.new("Gemfile").expand_path }
+
+ it "returns the Gemfile path" do
+ expect(subject.default_gemfile).to eq(expected_gemfile_path)
+ end
+ end
end
describe "#default_lockfile" do
@@ -121,14 +131,6 @@ RSpec.describe Bundler::SharedHelpers do
end
end
- context "ENV['BUNDLE_GEMFILE'] is set without an absolute path" do
- before { ENV["BUNDLE_GEMFILE"] = "Gemfile" }
-
- it "returns path of the bundle Gemfile" do
- expect(subject.in_bundle?).to eq("#{bundled_app}/Gemfile")
- end
- end
-
context "ENV['BUNDLE_GEMFILE'] not set" do
before { ENV["BUNDLE_GEMFILE"] = nil }
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 909378ab02..34caceba5a 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -269,21 +269,51 @@ RSpec.describe "Bundler.setup" do
expect(bundled_app("Gemfile.lock")).to exist
end
- it "uses BUNDLE_GEMFILE to locate the gemfile if present" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- G
+ describe "$BUNDLE_GEMFILE" do
+ context "user provides an absolute path" do
+ it "uses BUNDLE_GEMFILE to locate the gemfile if present" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
- gemfile bundled_app("4realz"), <<-G
- source "file://#{gem_repo1}"
- gem "activesupport", "2.3.5"
- G
+ gemfile bundled_app("4realz"), <<-G
+ source "file://#{gem_repo1}"
+ gem "activesupport", "2.3.5"
+ G
+
+ ENV["BUNDLE_GEMFILE"] = bundled_app("4realz").to_s
+ bundle :install
+
+ expect(the_bundle).to include_gems "activesupport 2.3.5"
+ end
+ end
+
+ context "an absolute path is not provided" do
+ it "uses BUNDLE_GEMFILE to locate the gemfile if present" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ G
- ENV["BUNDLE_GEMFILE"] = bundled_app("4realz").to_s
- bundle :install
+ bundle "install"
+ bundle "install --deployment"
- expect(the_bundle).to include_gems "activesupport 2.3.5"
+ ENV["BUNDLE_GEMFILE"] = "Gemfile"
+ ruby <<-R
+ require 'rubygems'
+ require 'bundler'
+
+ begin
+ Bundler.setup
+ puts "WIN"
+ rescue ArgumentError => e
+ puts "FAIL"
+ end
+ R
+
+ expect(out).to eq("WIN")
+ end
+ end
end
it "prioritizes gems in BUNDLE_PATH over gems in GEM_HOME" do