diff options
Diffstat (limited to 'spec/bundler/runtime/self_management_spec.rb')
-rw-r--r-- | spec/bundler/runtime/self_management_spec.rb | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/spec/bundler/runtime/self_management_spec.rb b/spec/bundler/runtime/self_management_spec.rb index 0032c6aef6..d15ca3189e 100644 --- a/spec/bundler/runtime/self_management_spec.rb +++ b/spec/bundler/runtime/self_management_spec.rb @@ -1,11 +1,15 @@ # frozen_string_literal: true -RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev", :realworld => true do +RSpec.describe "Self management", rubygems: ">= 3.3.0.dev", realworld: true do describe "auto switching" do let(:previous_minor) do "2.3.0" end + let(:current_version) do + "2.4.0" + end + before do build_repo2 @@ -20,19 +24,19 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev", :realworld => tru lockfile_bundled_with(previous_minor) bundle "config set --local path.system true" - bundle "install", :artifice => "vcr" + bundle "install", artifice: "vcr" expect(out).to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.") # It uninstalls the older system bundler - bundle "clean --force" + bundle "clean --force", artifice: nil expect(out).to eq("Removing bundler (#{Bundler::VERSION})") # App now uses locked version - bundle "-v" + bundle "-v", artifice: nil expect(out).to end_with(previous_minor[0] == "2" ? "Bundler version #{previous_minor}" : previous_minor) # Subsequent installs use the locked version without reinstalling - bundle "install --verbose" + bundle "install --verbose", artifice: nil expect(out).to include("Using bundler #{previous_minor}") expect(out).not_to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.") end @@ -41,7 +45,7 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev", :realworld => tru lockfile_bundled_with(previous_minor) bundle "config set --local path vendor/bundle" - bundle "install", :artifice => "vcr" + bundle "install", artifice: "vcr" expect(out).to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.") expect(vendored_gems("gems/bundler-#{previous_minor}")).to exist @@ -63,7 +67,7 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev", :realworld => tru lockfile_bundled_with(previous_minor) bundle "config set --local deployment true" - bundle "install", :artifice => "vcr" + bundle "install", artifice: "vcr" expect(out).to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.") expect(vendored_gems("gems/bundler-#{previous_minor}")).to exist @@ -91,18 +95,47 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev", :realworld => tru expect(out).to eq(Bundler::VERSION[0] == "2" ? "Bundler version #{Bundler::VERSION}" : Bundler::VERSION) end - it "shows a discreet message if locked bundler does not exist" do - missing_minor ="#{Bundler::VERSION[0]}.999.999" + it "shows a discrete message if locked bundler does not exist" do + missing_minor = "#{Bundler::VERSION[0]}.999.999" lockfile_bundled_with(missing_minor) - bundle "install", :artifice => "vcr" + bundle "install", artifice: "vcr" expect(err).to eq("Your lockfile is locked to a version of bundler (#{missing_minor}) that doesn't exist at https://rubygems.org/. Going on using #{Bundler::VERSION}") bundle "-v" expect(out).to eq(Bundler::VERSION[0] == "2" ? "Bundler version #{Bundler::VERSION}" : Bundler::VERSION) end + it "installs BUNDLE_VERSION version when using bundle config version x.y.z" do + lockfile_bundled_with(current_version) + + bundle "config set --local version #{previous_minor}" + bundle "install", artifice: "vcr" + expect(out).to include("Bundler #{Bundler::VERSION} is running, but your configuration was #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.") + + bundle "-v" + expect(out).to eq(previous_minor[0] == "2" ? "Bundler version #{previous_minor}" : previous_minor) + end + + it "does not try to install when using bundle config version global" do + lockfile_bundled_with(previous_minor) + + bundle "config set version system" + bundle "install", artifice: "vcr" + expect(out).not_to match(/restarting using that version/) + + bundle "-v" + expect(out).to eq(Bundler::VERSION[0] == "2" ? "Bundler version #{Bundler::VERSION}" : Bundler::VERSION) + end + + it "ignores malformed lockfile version" do + lockfile_bundled_with("2.3.") + + bundle "install --verbose" + expect(out).to include("Using bundler #{Bundler::VERSION}") + end + private def lockfile_bundled_with(version) |