From 2953979277ea07ac0a55bc7e661a97707e502489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sun, 10 Nov 2019 19:16:54 +0100 Subject: Improve binstub specs --- spec/commands/binstubs_spec.rb | 75 +++++++++++++++++++++++++++--------------- 1 file 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 " 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 -- cgit v1.2.1