From dd28c03d5fd7a82d1b694a9c2332a55dab81add9 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 14 Jun 2021 12:54:37 +0900 Subject: Merge RubyGems-3.2.17 and Bundler-2.2.17 --- spec/bundler/commands/cache_spec.rb | 15 ++ spec/bundler/commands/config_spec.rb | 8 + spec/bundler/commands/newgem_spec.rb | 2 +- spec/bundler/commands/outdated_spec.rb | 353 +++++++++++++++++++++++++++++++-- spec/bundler/commands/pristine_spec.rb | 10 + spec/bundler/commands/remove_spec.rb | 4 +- spec/bundler/commands/update_spec.rb | 295 ++++++++++++++++++++------- 7 files changed, 590 insertions(+), 97 deletions(-) (limited to 'spec/bundler/commands') diff --git a/spec/bundler/commands/cache_spec.rb b/spec/bundler/commands/cache_spec.rb index df5f01bc45..f8fab594b8 100644 --- a/spec/bundler/commands/cache_spec.rb +++ b/spec/bundler/commands/cache_spec.rb @@ -255,6 +255,21 @@ RSpec.describe "bundle cache" do expect(the_bundle).to include_gem "rack 1.0" expect(the_bundle).not_to include_gems "weakling", "uninstallable" end + + it "does not fail to cache gems in excluded groups when there's a lockfile but gems not previously installed" do + bundle "config set --local without wo" + gemfile <<-G + source "https://my.gem.repo.1" + gem "rack" + group :wo do + gem "weakling" + end + G + + bundle :lock, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo1.to_s } + bundle :cache, "all-platforms" => true, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo1.to_s } + expect(bundled_app("vendor/cache/weakling-0.0.3.gem")).to exist + end end context "with frozen configured" do diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index 70e3feff00..33677cf4ad 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -408,6 +408,14 @@ E expect(out).to eq "spec_run=true" end + it "list with credentials" do + bundle "config list", :env => { "BUNDLE_GEMS__MYSERVER__COM" => "user:password" } + expect(out).to eq "Settings are listed in order of priority. The top value will be used.\ngems.myserver.com\nSet via BUNDLE_GEMS__MYSERVER__COM: \"user:[REDACTED]\"\n\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\"" + + bundle "config list", :parseable => true, :env => { "BUNDLE_GEMS__MYSERVER__COM" => "user:password" } + expect(out).to eq "gems.myserver.com=user:password\nspec_run=true" + end + it "get" do ENV["BUNDLE_BAR"] = "bar_val" diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb index ac452a737a..57932fb013 100644 --- a/spec/bundler/commands/newgem_spec.rb +++ b/spec/bundler/commands/newgem_spec.rb @@ -97,7 +97,7 @@ RSpec.describe "bundle gem" do expect(bundled_app("#{gem_name}/README.md").read).to match(%r{https://github\.com/bundleuser/#{gem_name}/blob/.*/CODE_OF_CONDUCT.md}) end - it "generates the README with a section for the Code of Conduct, respecting the configured git default branch" do + it "generates the README with a section for the Code of Conduct, respecting the configured git default branch", :git => ">= 2.28.0" do sys_exec("git config --global init.defaultBranch main") bundle "gem #{gem_name} --coc" diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb index 7c4005824c..b0f0448655 100644 --- a/spec/bundler/commands/outdated_spec.rb +++ b/spec/bundler/commands/outdated_spec.rb @@ -1,24 +1,24 @@ # frozen_string_literal: true RSpec.describe "bundle outdated" do - before :each do - build_repo2 do - build_git "foo", :path => lib_path("foo") - build_git "zebra", :path => lib_path("zebra") - end - - install_gemfile <<-G - source "#{file_uri_for(gem_repo2)}" - gem "zebra", :git => "#{lib_path("zebra")}" - gem "foo", :git => "#{lib_path("foo")}" - gem "activesupport", "2.3.5" - gem "weakling", "~> 0.0.1" - gem "duradura", '7.0' - gem "terranova", '8' - G - end - describe "with no arguments" do + before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "zebra", :git => "#{lib_path("zebra")}" + gem "foo", :git => "#{lib_path("foo")}" + gem "activesupport", "2.3.5" + gem "weakling", "~> 0.0.1" + gem "duradura", '7.0' + gem "terranova", '8' + G + end + it "returns a sorted list of outdated gems" do update_repo2 do build_gem "activesupport", "3.0" @@ -102,6 +102,23 @@ RSpec.describe "bundle outdated" do end describe "with --verbose option" do + before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "zebra", :git => "#{lib_path("zebra")}" + gem "foo", :git => "#{lib_path("foo")}" + gem "activesupport", "2.3.5" + gem "weakling", "~> 0.0.1" + gem "duradura", '7.0' + gem "terranova", '8' + G + end + it "shows the location of the latest version's gemspec if installed" do bundle "config set clean false" @@ -134,8 +151,79 @@ RSpec.describe "bundle outdated" do end end + describe "with multiple, duplicated sources, with lockfile in old format", :bundler => "< 3" do + before do + build_repo2 do + build_gem "dotenv", "2.7.6" + + build_gem "oj", "3.11.3" + build_gem "oj", "3.11.5" + + build_gem "vcr", "6.0.0" + end + + build_repo gem_repo3 do + build_gem "pkg-gem-flowbyte-with-dep", "1.0.0" do |s| + s.add_dependency "oj" + end + end + + gemfile <<~G + source "https://gem.repo2" + + gem "dotenv" + + source "https://gem.repo3" do + gem 'pkg-gem-flowbyte-with-dep' + end + + gem "vcr",source: "https://gem.repo2" + G + + lockfile <<~L + GEM + remote: https://gem.repo2/ + remote: https://gem.repo3/ + specs: + dotenv (2.7.6) + oj (3.11.3) + pkg-gem-flowbyte-with-dep (1.0.0) + oj + vcr (6.0.0) + + PLATFORMS + #{specific_local_platform} + + DEPENDENCIES + dotenv + pkg-gem-flowbyte-with-dep! + vcr! + + BUNDLED WITH + #{Bundler::VERSION} + L + end + + it "works" do + bundle :install, :artifice => :compact_index + bundle :outdated, :artifice => :compact_index, :raise_on_error => false + + expected_output = <<~TABLE + Gem Current Latest Requested Groups + oj 3.11.3 3.11.5 + TABLE + + expect(out).to include(expected_output.strip) + end + end + describe "with --group option" do before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" @@ -201,7 +289,10 @@ RSpec.describe "bundle outdated" do describe "with --groups option and outdated transitive dependencies" do before do - update_repo2 do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + build_gem "bar", %w[2.0.0] build_gem "bar_dependant", "7.0" do |s| @@ -234,6 +325,11 @@ RSpec.describe "bundle outdated" do describe "with --groups option" do before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" @@ -272,6 +368,24 @@ RSpec.describe "bundle outdated" do end describe "with --local option" do + before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + + gem "weakling", "~> 0.0.1" + gem "terranova", '8' + group :development, :test do + gem 'activesupport', '2.3.5' + gem "duradura", '7.0' + end + G + end + it "uses local cache to return a list of outdated gems" do update_repo2 do build_gem "activesupport", "2.3.4" @@ -305,10 +419,23 @@ RSpec.describe "bundle outdated" do shared_examples_for "a minimal output is desired" do context "and gems are outdated" do before do - update_repo2 do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + build_gem "activesupport", "3.0" build_gem "weakling", "0.2" end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "zebra", :git => "#{lib_path("zebra")}" + gem "foo", :git => "#{lib_path("foo")}" + gem "activesupport", "2.3.5" + gem "weakling", "~> 0.0.1" + gem "duradura", '7.0' + gem "terranova", '8' + G end it "outputs a sorted list of outdated gems with a more minimal format" do @@ -341,6 +468,21 @@ RSpec.describe "bundle outdated" do describe "with specified gems" do it "returns list of outdated gems" do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "zebra", :git => "#{lib_path("zebra")}" + gem "foo", :git => "#{lib_path("foo")}" + gem "activesupport", "2.3.5" + gem "weakling", "~> 0.0.1" + gem "duradura", '7.0' + gem "terranova", '8' + G + update_repo2 do build_gem "activesupport", "3.0" update_git "foo", :path => lib_path("foo") @@ -358,6 +500,23 @@ RSpec.describe "bundle outdated" do end describe "pre-release gems" do + before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "zebra", :git => "#{lib_path("zebra")}" + gem "foo", :git => "#{lib_path("foo")}" + gem "activesupport", "2.3.5" + gem "weakling", "~> 0.0.1" + gem "duradura", '7.0' + gem "terranova", '8' + G + end + context "without the --pre option" do it "ignores pre-release versions" do update_repo2 do @@ -413,6 +572,23 @@ RSpec.describe "bundle outdated" do filter_strict_option = Bundler.feature_flag.bundler_2_mode? ? :"filter-strict" : :strict describe "with --#{filter_strict_option} option" do + before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "zebra", :git => "#{lib_path("zebra")}" + gem "foo", :git => "#{lib_path("foo")}" + gem "activesupport", "2.3.5" + gem "weakling", "~> 0.0.1" + gem "duradura", '7.0' + gem "terranova", '8' + G + end + it "only reports gems that have a newer version that matches the specified dependency version requirements" do update_repo2 do build_gem "activesupport", "3.0" @@ -521,6 +697,23 @@ RSpec.describe "bundle outdated" do end describe "with invalid gem name" do + before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "zebra", :git => "#{lib_path("zebra")}" + gem "foo", :git => "#{lib_path("foo")}" + gem "activesupport", "2.3.5" + gem "weakling", "~> 0.0.1" + gem "duradura", '7.0' + gem "terranova", '8' + G + end + it "returns could not find gem name" do bundle "outdated invalid_gem_name", :raise_on_error => false expect(err).to include("Could not find gem 'invalid_gem_name'.") @@ -546,12 +739,16 @@ RSpec.describe "bundle outdated" do context "after bundle install --deployment", :bundler => "< 3" do before do - install_gemfile <<-G, :deployment => true, :raise_on_error => false + build_repo2 + + gemfile <<-G source "#{file_uri_for(gem_repo2)}" gem "rack" gem "foo" G + bundle :lock + bundle :install, :deployment => true end it "outputs a helpful message about being in deployment mode" do @@ -568,6 +765,11 @@ RSpec.describe "bundle outdated" do context "after bundle config set --local deployment true" do before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" @@ -591,6 +793,8 @@ RSpec.describe "bundle outdated" do context "update available for a gem on a different platform" do before do + build_repo2 + install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" gem "laduradura", '= 5.15.2' @@ -604,6 +808,10 @@ RSpec.describe "bundle outdated" do end context "update available for a gem on the same platform while multiple platforms used for gem" do + before do + build_repo2 + end + it "reports that updates are available if the Ruby platform is used" do install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" @@ -643,6 +851,21 @@ RSpec.describe "bundle outdated" do shared_examples_for "major version updates are detected" do before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "zebra", :git => "#{lib_path("zebra")}" + gem "foo", :git => "#{lib_path("foo")}" + gem "activesupport", "2.3.5" + gem "weakling", "~> 0.0.1" + gem "duradura", '7.0' + gem "terranova", '8' + G + update_repo2 do build_gem "activesupport", "3.3.5" build_gem "weakling", "0.8.0" @@ -654,6 +877,21 @@ RSpec.describe "bundle outdated" do context "when on a new machine" do before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "zebra", :git => "#{lib_path("zebra")}" + gem "foo", :git => "#{lib_path("foo")}" + gem "activesupport", "2.3.5" + gem "weakling", "~> 0.0.1" + gem "duradura", '7.0' + gem "terranova", '8' + G + simulate_new_machine update_git "foo", :path => lib_path("foo") @@ -669,6 +907,21 @@ RSpec.describe "bundle outdated" do shared_examples_for "minor version updates are detected" do before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "zebra", :git => "#{lib_path("zebra")}" + gem "foo", :git => "#{lib_path("foo")}" + gem "activesupport", "2.3.5" + gem "weakling", "~> 0.0.1" + gem "duradura", '7.0' + gem "terranova", '8' + G + update_repo2 do build_gem "activesupport", "2.7.5" build_gem "weakling", "2.0.1" @@ -680,6 +933,21 @@ RSpec.describe "bundle outdated" do shared_examples_for "patch version updates are detected" do before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "zebra", :git => "#{lib_path("zebra")}" + gem "foo", :git => "#{lib_path("foo")}" + gem "activesupport", "2.3.5" + gem "weakling", "~> 0.0.1" + gem "duradura", '7.0' + gem "terranova", '8' + G + update_repo2 do build_gem "activesupport", "2.3.7" build_gem "weakling", "0.3.1" @@ -698,6 +966,21 @@ RSpec.describe "bundle outdated" do shared_examples_for "major version is ignored" do before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "zebra", :git => "#{lib_path("zebra")}" + gem "foo", :git => "#{lib_path("foo")}" + gem "activesupport", "2.3.5" + gem "weakling", "~> 0.0.1" + gem "duradura", '7.0' + gem "terranova", '8' + G + update_repo2 do build_gem "activesupport", "3.3.5" build_gem "weakling", "1.0.1" @@ -709,6 +992,21 @@ RSpec.describe "bundle outdated" do shared_examples_for "minor version is ignored" do before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "zebra", :git => "#{lib_path("zebra")}" + gem "foo", :git => "#{lib_path("foo")}" + gem "activesupport", "2.3.5" + gem "weakling", "~> 0.0.1" + gem "duradura", '7.0' + gem "terranova", '8' + G + update_repo2 do build_gem "activesupport", "2.4.5" build_gem "weakling", "0.3.1" @@ -720,6 +1018,21 @@ RSpec.describe "bundle outdated" do shared_examples_for "patch version is ignored" do before do + build_repo2 do + build_git "foo", :path => lib_path("foo") + build_git "zebra", :path => lib_path("zebra") + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "zebra", :git => "#{lib_path("zebra")}" + gem "foo", :git => "#{lib_path("foo")}" + gem "activesupport", "2.3.5" + gem "weakling", "~> 0.0.1" + gem "duradura", '7.0' + gem "terranova", '8' + G + update_repo2 do build_gem "activesupport", "2.3.6" build_gem "weakling", "0.0.4" diff --git a/spec/bundler/commands/pristine_spec.rb b/spec/bundler/commands/pristine_spec.rb index 6978f302c1..2f730bd4e2 100644 --- a/spec/bundler/commands/pristine_spec.rb +++ b/spec/bundler/commands/pristine_spec.rb @@ -203,6 +203,16 @@ RSpec.describe "bundle pristine", :ruby_repo do end end + context "when BUNDLE_GEMFILE doesn't exist" do + before do + bundle "pristine", :env => { "BUNDLE_GEMFILE" => "does/not/exist" }, :raise_on_error => false + end + + it "shows a meaningful error" do + expect(err).to eq("#{bundled_app("does/not/exist")} not found") + end + end + def find_spec(name) without_env_side_effects do Bundler.definition.specs[name].first diff --git a/spec/bundler/commands/remove_spec.rb b/spec/bundler/commands/remove_spec.rb index 46c42fea10..170545f80c 100644 --- a/spec/bundler/commands/remove_spec.rb +++ b/spec/bundler/commands/remove_spec.rb @@ -229,7 +229,7 @@ RSpec.describe "bundle remove" do end end - context "when the gem is present in mutiple groups" do + context "when the gem is present in multiple groups" do it "removes all empty blocks" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -333,7 +333,7 @@ RSpec.describe "bundle remove" do end describe "arbitrary gemfile" do - context "when mutiple gems are present in same line" do + context "when multiple gems are present in same line" do it "shows warning for gems not removed" do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index 0f17d931a3..51a0b925a3 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -1,18 +1,18 @@ # frozen_string_literal: true RSpec.describe "bundle update" do - before :each do - build_repo2 + describe "with no arguments" do + before do + build_repo2 - install_gemfile <<-G - source "#{file_uri_for(gem_repo2)}" - gem "activesupport" - gem "rack-obama" - gem "platform_specific" - G - end + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "activesupport" + gem "rack-obama" + gem "platform_specific" + G + end - describe "with no arguments", :bundler => "< 3" do it "updates the entire bundle" do update_repo2 do build_gem "rack", "1.2" do |s| @@ -39,7 +39,18 @@ RSpec.describe "bundle update" do end end - describe "with --all", :bundler => "3" do + describe "with --all" do + before do + build_repo2 + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "activesupport" + gem "rack-obama" + gem "platform_specific" + G + end + it "updates the entire bundle" do update_repo2 do build_gem "rack", "1.2" do |s| @@ -55,6 +66,8 @@ RSpec.describe "bundle update" do end it "doesn't delete the Gemfile.lock file if something goes wrong" do + install_gemfile "" + gemfile <<-G source "#{file_uri_for(gem_repo2)}" gem "activesupport" @@ -102,6 +115,17 @@ RSpec.describe "bundle update" do end describe "--quiet argument" do + before do + build_repo2 + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "activesupport" + gem "rack-obama" + gem "platform_specific" + G + end + it "hides UI messages" do bundle "update --quiet" expect(out).not_to include("Bundle updated!") @@ -109,6 +133,17 @@ RSpec.describe "bundle update" do end describe "with a top level dependency" do + before do + build_repo2 + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "activesupport" + gem "rack-obama" + gem "platform_specific" + G + end + it "unlocks all child dependencies that are unrelated to other locked dependencies" do update_repo2 do build_gem "rack", "1.2" do |s| @@ -124,6 +159,17 @@ RSpec.describe "bundle update" do end describe "with an unknown dependency" do + before do + build_repo2 + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "activesupport" + gem "rack-obama" + gem "platform_specific" + G + end + it "should inform the user" do bundle "update halting-problem-solver", :raise_on_error => false expect(err).to include "Could not find gem 'halting-problem-solver'" @@ -135,6 +181,17 @@ RSpec.describe "bundle update" do end describe "with a child dependency" do + before do + build_repo2 + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "activesupport" + gem "rack-obama" + gem "platform_specific" + G + end + it "should update the child dependency" do update_repo2 do build_gem "rack", "1.2" do |s| @@ -212,6 +269,17 @@ RSpec.describe "bundle update" do end describe "with --local option" do + before do + build_repo2 + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "activesupport" + gem "rack-obama" + gem "platform_specific" + G + end + it "doesn't hit repo2" do FileUtils.rm_rf(gem_repo2) @@ -221,6 +289,10 @@ RSpec.describe "bundle update" do end describe "with --group option" do + before do + build_repo2 + end + it "should update only specified group gems" do install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" @@ -257,7 +329,7 @@ RSpec.describe "bundle update" do end context "when there is a source with the same name as a gem in a group" do - before :each do + before do build_git "foo", :path => lib_path("activesupport") install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" @@ -299,6 +371,17 @@ RSpec.describe "bundle update" do end describe "in a frozen bundle" do + before do + build_repo2 + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "activesupport" + gem "rack-obama" + gem "platform_specific" + G + end + it "should fail loudly", :bundler => "< 3" do bundle "install --deployment" bundle "update", :all => true, :raise_on_error => false @@ -324,6 +407,10 @@ RSpec.describe "bundle update" do end describe "with --source option" do + before do + build_repo2 + end + it "should not update gems not included in the source that happen to have the same name", :bundler => "< 3" do install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" @@ -449,10 +536,130 @@ RSpec.describe "bundle update" do expect(the_bundle).to include_gems "harry 1.0", "fred 1.0", "george 1.0" end end + + it "shows the previous version of the gem when updated from rubygems source", :bundler => "< 3" do + build_repo2 + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "activesupport" + G + + bundle "update", :all => true + expect(out).to include("Using activesupport 2.3.5") + + update_repo2 do + build_gem "activesupport", "3.0" + end + + bundle "update", :all => true + expect(out).to include("Installing activesupport 3.0 (was 2.3.5)") + end + + context "with suppress_install_using_messages set" do + before { bundle "config set suppress_install_using_messages true" } + + it "only prints `Using` for versions that have changed" do + build_repo4 do + build_gem "bar" + build_gem "foo" + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "bar" + gem "foo" + G + + bundle "update", :all => true + expect(out).to match(/Resolving dependencies\.\.\.\.*\nBundle updated!/) + + update_repo4 do + build_gem "foo", "2.0" + end + + bundle "update", :all => true + out.sub!("Removing foo (1.0)\n", "") + expect(out).to match(/Resolving dependencies\.\.\.\.*\nFetching foo 2\.0 \(was 1\.0\)\nInstalling foo 2\.0 \(was 1\.0\)\nBundle updated/) + end + end + + it "shows error message when Gemfile.lock is not preset and gem is specified" do + gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "activesupport" + G + + bundle "update nonexisting", :raise_on_error => false + expect(err).to include("This Bundle hasn't been installed yet. Run `bundle install` to update and install the bundled gems.") + expect(exitstatus).to eq(22) + end + + context "with multiple, duplicated sources, with lockfile in old format", :bundler => "< 3" do + before do + build_repo2 do + build_gem "dotenv", "2.7.6" + + build_gem "oj", "3.11.3" + build_gem "oj", "3.11.5" + + build_gem "vcr", "6.0.0" + end + + build_repo gem_repo3 do + build_gem "pkg-gem-flowbyte-with-dep", "1.0.0" do |s| + s.add_dependency "oj" + end + end + + gemfile <<~G + source "https://gem.repo2" + + gem "dotenv" + + source "https://gem.repo3" do + gem 'pkg-gem-flowbyte-with-dep' + end + + gem "vcr",source: "https://gem.repo2" + G + + lockfile <<~L + GEM + remote: https://gem.repo2/ + remote: https://gem.repo3/ + specs: + dotenv (2.7.6) + oj (3.11.3) + pkg-gem-flowbyte-with-dep (1.0.0) + oj + vcr (6.0.0) + + PLATFORMS + #{specific_local_platform} + + DEPENDENCIES + dotenv + pkg-gem-flowbyte-with-dep! + vcr! + + BUNDLED WITH + #{Bundler::VERSION} + L + end + + it "works" do + bundle :install, :artifice => :compact_index + bundle "update oj", :artifice => :compact_index + + expect(out).to include("Bundle updated!") + expect(the_bundle).to include_gems "oj 3.11.5" + end + end end RSpec.describe "bundle update in more complicated situations" do - before :each do + before do build_repo2 end @@ -640,7 +847,7 @@ RSpec.describe "bundle update without a Gemfile.lock" do end RSpec.describe "bundle update when a gem depends on a newer version of bundler" do - before(:each) do + before do build_repo2 do build_gem "rails", "3.0.1" do |s| s.add_dependency "bundler", Bundler::VERSION.succ @@ -663,66 +870,6 @@ RSpec.describe "bundle update when a gem depends on a newer version of bundler" end end -RSpec.describe "bundle update" do - it "shows the previous version of the gem when updated from rubygems source", :bundler => "< 3" do - build_repo2 - - install_gemfile <<-G - source "#{file_uri_for(gem_repo2)}" - gem "activesupport" - G - - bundle "update", :all => true - expect(out).to include("Using activesupport 2.3.5") - - update_repo2 do - build_gem "activesupport", "3.0" - end - - bundle "update", :all => true - expect(out).to include("Installing activesupport 3.0 (was 2.3.5)") - end - - context "with suppress_install_using_messages set" do - before { bundle "config set suppress_install_using_messages true" } - - it "only prints `Using` for versions that have changed" do - build_repo4 do - build_gem "bar" - build_gem "foo" - end - - install_gemfile <<-G - source "#{file_uri_for(gem_repo4)}" - gem "bar" - gem "foo" - G - - bundle "update", :all => true - expect(out).to match(/Resolving dependencies\.\.\.\.*\nBundle updated!/) - - update_repo4 do - build_gem "foo", "2.0" - end - - bundle "update", :all => true - out.sub!("Removing foo (1.0)\n", "") - expect(out).to match(/Resolving dependencies\.\.\.\.*\nFetching foo 2\.0 \(was 1\.0\)\nInstalling foo 2\.0 \(was 1\.0\)\nBundle updated/) - end - end - - it "shows error message when Gemfile.lock is not preset and gem is specified" do - gemfile <<-G - source "#{file_uri_for(gem_repo2)}" - gem "activesupport" - G - - bundle "update nonexisting", :raise_on_error => false - expect(err).to include("This Bundle hasn't been installed yet. Run `bundle install` to update and install the bundled gems.") - expect(exitstatus).to eq(22) - end -end - RSpec.describe "bundle update --ruby" do before do install_gemfile <<-G -- cgit v1.2.3