aboutsummaryrefslogtreecommitdiffstats
path: root/spec/bundler
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2021-12-27 09:41:55 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-12-27 10:45:36 +0900
commitd6311cb1ca5860a6e0cbf6f87c1e0ae9e099f61e (patch)
treed9bd1de350a80822894e49b48f9d70d764bf7700 /spec/bundler
parentb7e5ce08ff0196c1a9ed885670495cf09a02bbc3 (diff)
downloadruby-d6311cb1ca5860a6e0cbf6f87c1e0ae9e099f61e.tar.gz
Track RubyGems 3.4.0dev and Bundler 2.4.0dev
Diffstat (limited to 'spec/bundler')
-rw-r--r--spec/bundler/commands/binstubs_spec.rb22
-rw-r--r--spec/bundler/commands/install_spec.rb24
-rw-r--r--spec/bundler/lock/lockfile_spec.rb16
-rw-r--r--spec/bundler/realworld/fixtures/warbler/Gemfile.lock2
-rw-r--r--spec/bundler/runtime/self_management_spec.rb62
5 files changed, 64 insertions, 62 deletions
diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb
index ceef07d36b..14b0069b6e 100644
--- a/spec/bundler/commands/binstubs_spec.rb
+++ b/spec/bundler/commands/binstubs_spec.rb
@@ -182,30 +182,26 @@ RSpec.describe "bundle binstubs <gem>" do
end
context "and the version is older and the same major" do
- let(:system_bundler_version) { "55.1" }
+ let(:system_bundler_version) { "2.3.1" }
before do
- lockfile lockfile.gsub(/BUNDLED WITH\n .*$/m, "BUNDLED WITH\n 55.0")
-
- update_repo2 do
- with_built_bundler("55.0") {|gem_path| FileUtils.mv(gem_path, gem_repo2("gems")) }
- end
+ lockfile lockfile.gsub(/BUNDLED WITH\n .*$/m, "BUNDLED WITH\n 2.3.0")
end
it "installs and runs the exact version of bundler", :rubygems => ">= 3.3.0.dev" do
- sys_exec "bin/bundle install --verbose", :env => { "BUNDLER_SPEC_GEM_SOURCES" => file_uri_for(gem_repo2).to_s, "RUBYOPT" => "-r#{spec_dir}/support/hax.rb" }
+ sys_exec "bin/bundle install --verbose", :artifice => "vcr"
expect(exitstatus).not_to eq(42)
- expect(out).to include("Bundler 55.1 is running, but your lockfile was generated with 55.0. Installing Bundler 55.0 and restarting using that version.")
- expect(out).to include("Using bundler 55.0")
- expect(err).not_to include("Activating bundler (~> 55.0) failed:")
+ expect(out).to include("Bundler 2.3.1 is running, but your lockfile was generated with 2.3.0. Installing Bundler 2.3.0 and restarting using that version.")
+ expect(out).to include("Using bundler 2.3.0")
+ expect(err).not_to include("Activating bundler (~> 2.3.0) failed:")
end
it "runs the available version of bundler", :rubygems => "< 3.3.0.dev" do
sys_exec "bin/bundle install --verbose"
expect(exitstatus).not_to eq(42)
- expect(out).not_to include("Bundler 55.1 is running, but your lockfile was generated with 55.0. Installing Bundler 55.0 and restarting using that version.")
- expect(out).to include("Using bundler 55.1")
- expect(err).not_to include("Activating bundler (~> 55.0) failed:")
+ expect(out).not_to include("Bundler 2.3.1 is running, but your lockfile was generated with 2.3.0. Installing Bundler 2.3.0 and restarting using that version.")
+ expect(out).to include("Using bundler 2.3.1")
+ expect(err).not_to include("Activating bundler (~> 2.3.0) failed:")
end
end
diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb
index ec1d9bcd02..56f657521f 100644
--- a/spec/bundler/commands/install_spec.rb
+++ b/spec/bundler/commands/install_spec.rb
@@ -364,7 +364,9 @@ RSpec.describe "bundle install with gem sources" do
end
it "throws a warning if a gem is added twice in Gemfile without version requirements" do
- install_gemfile <<-G, :raise_on_error => false
+ build_repo2
+
+ install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "rack"
gem "rack"
@@ -376,7 +378,9 @@ RSpec.describe "bundle install with gem sources" do
end
it "throws a warning if a gem is added twice in Gemfile with same versions" do
- install_gemfile <<-G, :raise_on_error => false
+ build_repo2
+
+ install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "rack", "1.0"
gem "rack", "1.0"
@@ -387,6 +391,22 @@ RSpec.describe "bundle install with gem sources" do
expect(err).to include("While it's not a problem now, it could cause errors if you change the version of one of them later.")
end
+ it "throws a warning if a gem is added twice under different platforms and does not crash when using the generated lockfile" do
+ build_repo2
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ gem "rack", :platform => :jruby
+ gem "rack"
+ G
+
+ bundle "install"
+
+ expect(err).to include("Your Gemfile lists the gem rack (>= 0) more than once.")
+ expect(err).to include("Remove any duplicate entries and specify the gem only once.")
+ expect(err).to include("While it's not a problem now, it could cause errors if you change the version of one of them later.")
+ end
+
it "does not throw a warning if a gem is added once in Gemfile and also inside a gemspec as a development dependency" do
build_lib "my-gem", :path => bundled_app do |s|
s.add_development_dependency "my-private-gem"
diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb
index b07b0b0f91..561de9f3bc 100644
--- a/spec/bundler/lock/lockfile_spec.rb
+++ b/spec/bundler/lock/lockfile_spec.rb
@@ -80,12 +80,8 @@ RSpec.describe "the lockfile format" do
G
end
- it "does not update the lockfile's bundler version if nothing changed during bundle install, but uses the locked version", :rubygems => ">= 3.3.0.a" do
- version = "#{Bundler::VERSION.split(".").first}.0.0.a"
-
- update_repo2 do
- with_built_bundler(version) {|gem_path| FileUtils.mv(gem_path, gem_repo2("gems")) }
- end
+ it "does not update the lockfile's bundler version if nothing changed during bundle install, but uses the locked version", :rubygems => ">= 3.3.0.a", :realworld => true do
+ version = "2.3.0"
lockfile <<-L
GEM
@@ -103,7 +99,7 @@ RSpec.describe "the lockfile format" do
#{version}
L
- install_gemfile <<-G, :verbose => true, :env => { "BUNDLER_SPEC_GEM_SOURCES" => file_uri_for(gem_repo2).to_s }
+ install_gemfile <<-G, :verbose => true, :artifice => "vcr"
source "#{file_uri_for(gem_repo2)}"
gem "rack"
@@ -132,10 +128,6 @@ RSpec.describe "the lockfile format" do
it "does not update the lockfile's bundler version if nothing changed during bundle install, and uses the latest version", :rubygems => "< 3.3.0.a" do
version = "#{Bundler::VERSION.split(".").first}.0.0.a"
- update_repo2 do
- with_built_bundler(version) {|gem_path| FileUtils.mv(gem_path, gem_repo2("gems")) }
- end
-
lockfile <<-L
GEM
remote: #{file_uri_for(gem_repo2)}/
@@ -152,7 +144,7 @@ RSpec.describe "the lockfile format" do
#{version}
L
- install_gemfile <<-G, :verbose => true, :env => { "BUNDLER_SPEC_GEM_SOURCES" => file_uri_for(gem_repo2).to_s }
+ install_gemfile <<-G, :verbose => true
source "#{file_uri_for(gem_repo2)}"
gem "rack"
diff --git a/spec/bundler/realworld/fixtures/warbler/Gemfile.lock b/spec/bundler/realworld/fixtures/warbler/Gemfile.lock
index 05bcb877db..8f29bd341f 100644
--- a/spec/bundler/realworld/fixtures/warbler/Gemfile.lock
+++ b/spec/bundler/realworld/fixtures/warbler/Gemfile.lock
@@ -27,4 +27,4 @@ DEPENDENCIES
warbler (~> 2.0)
BUNDLED WITH
- 2.3.0.dev
+ 2.4.0.dev
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)