diff options
author | Bundlerbot <bot@bundler.io> | 2019-11-11 21:07:49 +0000 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-11-11 23:17:30 +0100 |
commit | 70ef6a98897e5330e94989e3fa1477725b323dd6 (patch) | |
tree | 4a8cb9ff12253ccacae432a6919e2ae30d9a38fc | |
parent | 4195b12cde389f8f21dec69e27742bdfac7c644b (diff) | |
download | bundler-70ef6a98897e5330e94989e3fa1477725b323dd6.tar.gz |
Merge #7433
7433: Improve binstub specs r=deivid-rodriguez a=deivid-rodriguez
### What was the end-user problem that led to this PR?
The problem was that I run into some failures when testing rubygems against the latest bundler 2-1-stable branch of bundler.
### What was your diagnosis of the problem?
In certain contexts, the previous approach of overwriting the version constant led into version mismatch issues.
### What is your fix for the problem, implemented in this PR?
Since in this case we are actually testing some rubygems stuff present in the generated binstub, but we don't really care what the bundler gem is actually doing, we can follow the same approach as other specs and install a "dummy" bundler gem to the system gems home used by our specs.
### Why did you choose this fix out of the possible options?
I chose this fix because it still tests the same thing but in a more resilient way, I believe.
Co-authored-by: David RodrÃguez <deivid.rodriguez@riseup.net>
(cherry picked from commit be3025b1d707f7666322b1b809d4056b43c327d2)
-rw-r--r-- | spec/commands/binstubs_spec.rb | 75 |
1 files changed, 49 insertions, 26 deletions
diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index 81b4d99064..df10bd3498 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -141,38 +141,61 @@ RSpec.describe "bundle binstubs <gem>" do end context "when a lockfile exists with a locked bundler version" do - 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" - expect(exitstatus).to eq(42) if exitstatus - expect(err).to include("Activating bundler (~> 999.999) failed:"). - and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`") + context "and the version is newer" do + before do + lockfile lockfile.gsub(system_bundler_version, "999.999") + end + + it "runs the correct version of bundler" do + sys_exec "#{bundled_app("bin/bundle")} install" + expect(exitstatus).to eq(42) if exitstatus + expect(err).to include("Activating bundler (~> 999.999) failed:"). + and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`") + end end - it "runs the correct version of bundler when the version is older and a different major" do - simulate_bundler_version "55" - lockfile lockfile.gsub(system_bundler_version, "44.0") - sys_exec "#{bundled_app("bin/bundle")} install" - expect(exitstatus).to eq(42) if exitstatus - expect(err).to include("Activating bundler (~> 44.0) failed:"). - and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 44.0'`") + context "and the version is older and a different major" do + let(:system_bundler_version) { "55" } + + before do + lockfile lockfile.gsub(/BUNDLED WITH\n .*$/m, "BUNDLED WITH\n 44.0") + end + + it "runs the correct version of bundler" do + sys_exec "#{bundled_app("bin/bundle")} install" + expect(exitstatus).to eq(42) if exitstatus + expect(err).to include("Activating bundler (~> 44.0) failed:"). + and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 44.0'`") + end end - it "runs the available version of bundler when the version is older and the same major" do - simulate_bundler_version "55.1" - lockfile lockfile.gsub(system_bundler_version, "55.0") - sys_exec "#{bundled_app("bin/bundle")} install" - expect(exitstatus).not_to eq(42) if exitstatus - expect(err).not_to include("Activating bundler (~> 55.0) failed:") + context "and the version is older and the same major" do + let(:system_bundler_version) { "55.1" } + + before do + lockfile lockfile.gsub(/BUNDLED WITH\n .*$/m, "BUNDLED WITH\n 55.0") + end + + it "runs the available version of bundler when the version is older and the same major" do + sys_exec "#{bundled_app("bin/bundle")} install" + expect(exitstatus).not_to eq(42) if exitstatus + expect(err).not_to include("Activating bundler (~> 55.0) failed:") + end end - it "runs the correct version of bundler when the version is a pre-release" do - simulate_bundler_version "55" - lockfile lockfile.gsub(system_bundler_version, "2.12.0.a") - sys_exec "#{bundled_app("bin/bundle")} install" - expect(exitstatus).to eq(42) if exitstatus - expect(err).to include("Activating bundler (~> 2.12.a) failed:"). - and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 2.12.a'`") + context "and the version is a pre-releaser" do + let(:system_bundler_version) { "55" } + + before do + lockfile lockfile.gsub(/BUNDLED WITH\n .*$/m, "BUNDLED WITH\n 2.12.0.a") + end + + it "runs the correct version of bundler when the version is a pre-release" do + sys_exec "#{bundled_app("bin/bundle")} install" + expect(exitstatus).to eq(42) if exitstatus + expect(err).to include("Activating bundler (~> 2.12.a) failed:"). + and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 2.12.a'`") + end end end |