summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-02-16 06:36:50 +0000
committerThe Bundler Bot <bot@bundler.io>2018-02-16 06:36:50 +0000
commit0f8d692e19a9c8efdf459f41d662f5baac22a9a1 (patch)
tree91cbceceb8b6e7bcfe3a492e8a37e651e8e2364d
parentf5a695745bed460344f6069eda3493e71e073182 (diff)
parentcf5dd0e6a35ddfc554f705099dfba207c3b54583 (diff)
downloadbundler-0f8d692e19a9c8efdf459f41d662f5baac22a9a1.tar.gz
Auto merge of #6291 - bundler:fixed-default-gems-1-16-1, r=segiddins
To use dynamic expectation with same versioned bundler installed as default gems I fixed test fails with bundler-1.16.1 as default gems. https://travis-ci.org/rubygems/rubygems/jobs/339325369 When the system has a same version of bundler as default gems(Currently it's 1.16.1), It conflicts on command invocation in bundler's examples. I added two workarounds. 1. Bump virtual version of bundler in `binstubs_spec.rb` 2. In other examples, I modified expected variables when it was installed bundler as default gems.
-rw-r--r--spec/commands/binstubs_spec.rb31
-rw-r--r--spec/commands/licenses_spec.rb9
-rw-r--r--spec/commands/pristine_spec.rb4
-rw-r--r--spec/commands/show_spec.rb9
-rw-r--r--spec/runtime/setup_spec.rb4
5 files changed, 46 insertions, 11 deletions
diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb
index 24ee03ec3c..ba50699ab1 100644
--- a/spec/commands/binstubs_spec.rb
+++ b/spec/commands/binstubs_spec.rb
@@ -100,14 +100,25 @@ RSpec.describe "bundle binstubs <gem>" do
bundle! "binstubs bundler rack prints_loaded_gems"
end
- let(:system_bundler_version) { Bundler::VERSION }
-
- it "runs bundler" do
- sys_exec! "#{bundled_app("bin/bundle")} install"
- expect(out).to eq %(system bundler #{system_bundler_version}\n["install"])
+ # When environment has a same version of bundler as default gems.
+ # `system_gems "bundler-x.y.z"` will detect system binstub.
+ # We need to avoid it by virtual version of bundler.
+ let(:system_bundler_version) { Gem::Version.new(Bundler::VERSION).bump.to_s }
+
+ context "when system bundler was used" do
+ # Support master branch of bundler
+ if ENV["BUNDLER_SPEC_SUB_VERSION"]
+ let(:system_bundler_version) { Bundler::VERSION }
+ end
+ it "runs bundler" do
+ sys_exec! "#{bundled_app("bin/bundle")} install"
+ expect(out).to eq %(system bundler #{system_bundler_version}\n["install"])
+ end
end
context "when BUNDLER_VERSION is set" do
+ let(:system_bundler_version) { Bundler::VERSION }
+
it "runs the correct version of bundler" do
sys_exec "BUNDLER_VERSION='999.999.999' #{bundled_app("bin/bundle")} install"
expect(exitstatus).to eq(42) if exitstatus
@@ -117,6 +128,8 @@ RSpec.describe "bundle binstubs <gem>" do
end
context "when a lockfile exists with a locked bundler version" do
+ let(:system_bundler_version) { Bundler::VERSION }
+
it "runs the correct version of bundler when the version is newer" do
lockfile lockfile.gsub(system_bundler_version, "999.999.999")
sys_exec "#{bundled_app("bin/bundle")} install"
@@ -172,7 +185,13 @@ RSpec.describe "bundle binstubs <gem>" do
let(:system_bundler_version) { :bundler }
it "loads all gems" do
sys_exec! bundled_app("bin/print_loaded_gems").to_s
- expect(out).to eq %(["bundler-#{Bundler::VERSION}", "prints_loaded_gems-1.0", "rack-1.2"])
+ # RG < 2.0.14 didn't have a `Gem::Specification#default_gem?`
+ # This is dirty detection for old RG versions.
+ if File.dirname(Bundler.load.specs["bundler"][0].loaded_from) =~ %r{specifications/default}
+ expect(out).to eq %(["prints_loaded_gems-1.0", "rack-1.2"])
+ else
+ expect(out).to eq %(["bundler-#{Bundler::VERSION}", "prints_loaded_gems-1.0", "rack-1.2"])
+ end
end
context "when requesting a different bundler version" do
diff --git a/spec/commands/licenses_spec.rb b/spec/commands/licenses_spec.rb
index 144931fb27..d61d3492f3 100644
--- a/spec/commands/licenses_spec.rb
+++ b/spec/commands/licenses_spec.rb
@@ -12,7 +12,14 @@ RSpec.describe "bundle licenses" do
it "prints license information for all gems in the bundle" do
bundle "licenses"
- expect(out).to include("bundler: Unknown")
+ loaded_bundler_spec = Bundler.load.specs["bundler"]
+ expected = if !loaded_bundler_spec.empty?
+ loaded_bundler_spec[0].license
+ else
+ "Unknown"
+ end
+
+ expect(out).to include("bundler: #{expected}")
expect(out).to include("with_license: MIT")
end
diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb
index 4642a8167d..54eb2c0b20 100644
--- a/spec/commands/pristine_spec.rb
+++ b/spec/commands/pristine_spec.rb
@@ -46,9 +46,7 @@ RSpec.describe "bundle pristine" do
bundle! "install"
bundle! "pristine", :system_bundler => true
bundle! "-v", :system_bundler => true
- # An old rubygems couldn't handle a correct version of vendoered bundler.
- bundler_version = Gem::VERSION < "2.1" ? "1.16.0" : Bundler::VERSION
- expect(out).to end_with(bundler_version)
+ expect(out).to end_with(Bundler::VERSION)
end
end
diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb
index 0bdf6a4a9c..93734e4bc9 100644
--- a/spec/commands/show_spec.rb
+++ b/spec/commands/show_spec.rb
@@ -63,9 +63,16 @@ RSpec.describe "bundle show", :bundler => "< 2" do
it "prints summary of gems" do
bundle "show --verbose"
+ loaded_bundler_spec = Bundler.load.specs["bundler"]
+ expected = if !loaded_bundler_spec.empty?
+ loaded_bundler_spec[0].homepage
+ else
+ "No website available."
+ end
+
expect(out).to include("* actionmailer (2.3.2)")
expect(out).to include("\tSummary: This is just a fake gem for testing")
- expect(out).to include("\tHomepage: No website available.")
+ expect(out).to include("\tHomepage: #{expected}")
expect(out).to include("\tStatus: Up to date")
end
end
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index d758232723..e41bfdf32c 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -159,6 +159,10 @@ RSpec.describe "Bundler.setup" do
load_path = clean_load_path(out.split("\n"))
+ unless Bundler.load.specs["bundler"].empty?
+ load_path.delete_if {|path| path =~ /bundler/ }
+ end
+
expect(load_path).to start_with(
"/gems/rails-2.3.2/lib",
"/gems/activeresource-2.3.2/lib",