summaryrefslogtreecommitdiff
path: root/spec/bundler/runtime/self_management_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/bundler/runtime/self_management_spec.rb')
-rw-r--r--spec/bundler/runtime/self_management_spec.rb62
1 files changed, 28 insertions, 34 deletions
diff --git a/spec/bundler/runtime/self_management_spec.rb b/spec/bundler/runtime/self_management_spec.rb
index 7746a6ffa9..0032c6aef6 100644
--- a/spec/bundler/runtime/self_management_spec.rb
+++ b/spec/bundler/runtime/self_management_spec.rb
@@ -1,15 +1,13 @@
# frozen_string_literal: true
-RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev" do
+RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev", :realworld => true do
describe "auto switching" do
- let(:next_minor) do
- Bundler::VERSION.split(".").map.with_index {|s, i| i == 1 ? s.to_i + 1 : s }[0..2].join(".")
+ let(:previous_minor) do
+ "2.3.0"
end
before do
- build_repo2 do
- with_built_bundler(next_minor) {|gem_path| FileUtils.mv(gem_path, gem_repo2("gems")) }
- end
+ build_repo2
gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
@@ -19,11 +17,11 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev" do
end
it "installs locked version when using system path and uses it" do
- lockfile_bundled_with(next_minor)
+ lockfile_bundled_with(previous_minor)
bundle "config set --local path.system true"
- bundle "install", :env => { "BUNDLER_SPEC_GEM_SOURCES" => file_uri_for(gem_repo2).to_s }
- expect(out).to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{next_minor}. Installing Bundler #{next_minor} and restarting using that version.")
+ 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"
@@ -31,21 +29,21 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev" do
# App now uses locked version
bundle "-v"
- expect(out).to end_with(next_minor[0] == "2" ? "Bundler version #{next_minor}" : next_minor)
+ 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"
- expect(out).to include("Using bundler #{next_minor}")
- expect(out).not_to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{next_minor}. Installing Bundler #{next_minor} and restarting using that version.")
+ 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
it "installs locked version when using local path and uses it" do
- lockfile_bundled_with(next_minor)
+ lockfile_bundled_with(previous_minor)
bundle "config set --local path vendor/bundle"
- bundle "install", :env => { "BUNDLER_SPEC_GEM_SOURCES" => file_uri_for(gem_repo2).to_s }
- expect(out).to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{next_minor}. Installing Bundler #{next_minor} and restarting using that version.")
- expect(vendored_gems("gems/bundler-#{next_minor}")).to exist
+ 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
# It does not uninstall the locked bundler
bundle "clean"
@@ -53,21 +51,21 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev" do
# App now uses locked version
bundle "-v"
- expect(out).to end_with(next_minor[0] == "2" ? "Bundler version #{next_minor}" : next_minor)
+ 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"
- expect(out).to include("Using bundler #{next_minor}")
- expect(out).not_to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{next_minor}. Installing Bundler #{next_minor} and restarting using that version.")
+ 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
it "installs locked version when using deployment option and uses it" do
- lockfile_bundled_with(next_minor)
+ lockfile_bundled_with(previous_minor)
bundle "config set --local deployment true"
- bundle "install", :env => { "BUNDLER_SPEC_GEM_SOURCES" => file_uri_for(gem_repo2).to_s }
- expect(out).to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{next_minor}. Installing Bundler #{next_minor} and restarting using that version.")
- expect(vendored_gems("gems/bundler-#{next_minor}")).to exist
+ 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
# It does not uninstall the locked bundler
bundle "clean"
@@ -75,16 +73,16 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev" do
# App now uses locked version
bundle "-v"
- expect(out).to end_with(next_minor[0] == "2" ? "Bundler version #{next_minor}" : next_minor)
+ 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"
- expect(out).to include("Using bundler #{next_minor}")
- expect(out).not_to include("Bundler #{Bundler::VERSION} is running, but your lockfile was generated with #{next_minor}. Installing Bundler #{next_minor} and restarting using that version.")
+ 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
it "does not try to install a development version" do
- lockfile_bundled_with("#{next_minor}.dev")
+ lockfile_bundled_with("#{previous_minor}.dev")
bundle "install --verbose"
expect(out).not_to match(/restarting using that version/)
@@ -93,17 +91,13 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev" do
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, and something more complete in `--verbose` mode" do
+ it "shows a discreet message if locked bundler does not exist" do
missing_minor ="#{Bundler::VERSION[0]}.999.999"
lockfile_bundled_with(missing_minor)
- bundle "install"
- expect(err).to eq("There was an error installing the locked bundler version (#{missing_minor}), rerun with the `--verbose` flag for more details. Going on using bundler #{Bundler::VERSION}.")
-
- bundle "install --verbose"
- expect(err).to include("There was an error installing the locked bundler version (#{missing_minor}), rerun with the `--verbose` flag for more details. Going on using bundler #{Bundler::VERSION}.")
- expect(err).to include("Gem::UnsatisfiableDependencyError")
+ 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)