diff options
Diffstat (limited to 'spec/bundler/commands/update_spec.rb')
-rw-r--r-- | spec/bundler/commands/update_spec.rb | 258 |
1 files changed, 233 insertions, 25 deletions
diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index 403a48a508..ee5d53c527 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -980,20 +980,14 @@ RSpec.describe "bundle update when a gem depends on a newer version of bundler" end RSpec.describe "bundle update --ruby" do - before do - install_gemfile <<-G - ::RUBY_VERSION = '2.1.3' - ::RUBY_PATCHLEVEL = 100 - ruby '~> 2.1.0' - source "#{file_uri_for(gem_repo1)}" - G - end - context "when the Gemfile removes the ruby" do before do + install_gemfile <<-G + ruby '~> #{RUBY_VERSION}' + source "#{file_uri_for(gem_repo1)}" + G + gemfile <<-G - ::RUBY_VERSION = '2.1.4' - ::RUBY_PATCHLEVEL = 222 source "#{file_uri_for(gem_repo1)}" G end @@ -1018,10 +1012,13 @@ RSpec.describe "bundle update --ruby" do context "when the Gemfile specified an updated Ruby version" do before do + install_gemfile <<-G + ruby '~> #{RUBY_VERSION}' + source "#{file_uri_for(gem_repo1)}" + G + gemfile <<-G - ::RUBY_VERSION = '2.1.4' - ::RUBY_PATCHLEVEL = 222 - ruby '~> 2.1.0' + ruby '~> #{RUBY_VERSION[0..2]}' source "#{file_uri_for(gem_repo1)}" G end @@ -1039,7 +1036,7 @@ RSpec.describe "bundle update --ruby" do DEPENDENCIES RUBY VERSION - ruby 2.1.4p222 + #{Bundler::RubyVersion.system} BUNDLED WITH #{Bundler::VERSION} @@ -1049,9 +1046,12 @@ RSpec.describe "bundle update --ruby" do context "when a different Ruby is being used than has been versioned" do before do + install_gemfile <<-G + ruby '~> #{RUBY_VERSION}' + source "#{file_uri_for(gem_repo1)}" + G + gemfile <<-G - ::RUBY_VERSION = '2.2.2' - ::RUBY_PATCHLEVEL = 505 ruby '~> 2.1.0' source "#{file_uri_for(gem_repo1)}" G @@ -1059,16 +1059,31 @@ RSpec.describe "bundle update --ruby" do it "shows a helpful error message" do bundle "update --ruby", :raise_on_error => false - expect(err).to include("Your Ruby version is 2.2.2, but your Gemfile specified ~> 2.1.0") + expect(err).to include("Your Ruby version is #{Bundler::RubyVersion.system.gem_version}, but your Gemfile specified ~> 2.1.0") end end context "when updating Ruby version and Gemfile `ruby`" do before do + lockfile <<~L + GEM + remote: #{file_uri_for(gem_repo1)}/ + specs: + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + + RUBY VERSION + ruby 2.1.4p222 + + BUNDLED WITH + #{Bundler::VERSION} + L + gemfile <<-G - ::RUBY_VERSION = '1.8.3' - ::RUBY_PATCHLEVEL = 55 - ruby '~> 1.8.0' + ruby '~> #{RUBY_VERSION}' source "#{file_uri_for(gem_repo1)}" G end @@ -1086,7 +1101,7 @@ RSpec.describe "bundle update --ruby" do DEPENDENCIES RUBY VERSION - ruby 1.8.3p55 + #{Bundler::RubyVersion.system} BUNDLED WITH #{Bundler::VERSION} @@ -1105,15 +1120,208 @@ RSpec.describe "bundle update --bundler" do source "#{file_uri_for(gem_repo4)}" gem "rack" G - allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, '\11.0.0\2') FileUtils.rm_r gem_repo4 - bundle :update, :bundler => true, :verbose => true + bundle :update, :bundler => true, :artifice => "compact_index", :verbose => true + expect(out).to include("Using bundler #{Bundler::VERSION}") + + expect(lockfile).to eq <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + rack (1.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + #{Bundler::VERSION} + L + + expect(the_bundle).to include_gem "rack 1.0" + end + + it "updates the bundler version in the lockfile without re-resolving if the highest version is already installed" do + system_gems "bundler-2.3.3" + + build_repo4 do + build_gem "rack", "1.0" + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "rack" + G + lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.3") + + bundle :update, :bundler => true, :artifice => "compact_index", :verbose => true + expect(out).to include("Using bundler #{Bundler::VERSION}") + + expect(lockfile).to eq <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + rack (1.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + #{Bundler::VERSION} + L + expect(the_bundle).to include_gem "rack 1.0" + end + + it "updates the bundler version in the lockfile even if the latest version is not installed", :ruby_repo, :realworld do + pristine_system_gems "bundler-2.3.3" + + build_repo4 do + build_gem "rack", "1.0" + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "rack" + G + lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.3") + + bundle :update, :bundler => true, :artifice => "vcr", :verbose => true + + # Only updates properly on modern RubyGems. + + if Gem.rubygems_version >= Gem::Version.new("3.3.0.dev") + expect(out).to include("Updating bundler to 2.3.4") + expect(out).to include("Using bundler 2.3.4") + expect(out).not_to include("Installing Bundler 2.3.3 and restarting using that version.") + + expect(lockfile).to eq <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + rack (1.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + 2.3.4 + L + + expect(the_bundle).to include_gems "bundler 2.3.4" + end + + expect(the_bundle).to include_gems "rack 1.0" + end + + it "errors if the explicit target version does not exist", :realworld do + pristine_system_gems "bundler-2.3.3" + + build_repo4 do + build_gem "rack", "1.0" + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "rack" + G + lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.3") + + bundle :update, :bundler => "999.999.999", :artifice => "vcr", :raise_on_error => false - expect(the_bundle.locked_gems.bundler_version).to eq v(Bundler::VERSION) + # Only gives a meaningful error message on modern RubyGems. + + if Gem.rubygems_version >= Gem::Version.new("3.3.0.dev") + expect(last_command).to be_failure + expect(err).to include("The `bundle update --bundler` target version (999.999.999) does not exist") + end + end + + it "allows updating to development versions if already installed locally" do + system_gems "bundler-2.3.0.dev" + + build_repo4 do + build_gem "rack", "1.0" + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "rack" + G + + bundle :update, :bundler => "2.3.0.dev" + + # Only updates properly on modern RubyGems. + + if Gem.rubygems_version >= Gem::Version.new("3.3.0.dev") + expect(lockfile).to eq <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + rack (1.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + 2.3.0.dev + L + + expect(out).to include("Using bundler 2.3.0.dev") + end + end + + it "does not touch the network if not necessary" do + system_gems "bundler-2.3.3" + + build_repo4 do + build_gem "rack", "1.0" + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "rack" + G + + bundle :update, :bundler => "2.3.3", :raise_on_error => false + + expect(out).not_to include("Fetching gem metadata from https://rubygems.org/") + + # Only updates properly on modern RubyGems. + + if Gem.rubygems_version >= Gem::Version.new("3.3.0.dev") + expect(lockfile).to eq <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + rack (1.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + 2.3.3 + L + + expect(out).to include("Using bundler 2.3.3") + end end end |