diff options
Diffstat (limited to 'spec/bundler')
-rw-r--r-- | spec/bundler/bundler/cli_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/bundler/endpoint_specification_spec.rb | 7 | ||||
-rw-r--r-- | spec/bundler/commands/binstubs_spec.rb | 8 | ||||
-rw-r--r-- | spec/bundler/commands/update_spec.rb | 170 | ||||
-rw-r--r-- | spec/bundler/install/gemfile/gemspec_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/install/gems/dependency_api_spec.rb | 11 | ||||
-rw-r--r-- | spec/bundler/install/gems/resolving_spec.rb | 35 | ||||
-rw-r--r-- | spec/bundler/support/artifice/endpoint_api_missing.rb | 18 |
8 files changed, 206 insertions, 49 deletions
diff --git a/spec/bundler/bundler/cli_spec.rb b/spec/bundler/bundler/cli_spec.rb index c5de12c211..28ade90138 100644 --- a/spec/bundler/bundler/cli_spec.rb +++ b/spec/bundler/bundler/cli_spec.rb @@ -170,7 +170,7 @@ RSpec.describe "bundle executable" do bundle "fail", :env => { "BUNDLER_VERSION" => bundler_version }, :raise_on_error => false expect(err).to start_with(<<-EOS.strip) The latest bundler is #{latest_version}, but you are currently running #{bundler_version}. -To install the latest version, run `gem install bundler` +To update to the most recent version, run `bundle update --bundler` EOS end @@ -195,7 +195,7 @@ To install the latest version, run `gem install bundler` bundle "fail", :env => { "BUNDLER_VERSION" => bundler_version }, :raise_on_error => false expect(err).to start_with(<<-EOS.strip) The latest bundler is #{latest_version}, but you are currently running #{bundler_version}. -To install the latest version, run `gem install bundler --pre` +To update to the most recent version, run `bundle update --bundler` EOS end end diff --git a/spec/bundler/bundler/endpoint_specification_spec.rb b/spec/bundler/bundler/endpoint_specification_spec.rb index 2e2c16ec44..02a90d507a 100644 --- a/spec/bundler/bundler/endpoint_specification_spec.rb +++ b/spec/bundler/bundler/endpoint_specification_spec.rb @@ -5,9 +5,10 @@ RSpec.describe Bundler::EndpointSpecification do let(:version) { "1.0.0" } let(:platform) { Gem::Platform::RUBY } let(:dependencies) { [] } + let(:spec_fetcher) { double(:spec_fetcher) } let(:metadata) { nil } - subject(:spec) { described_class.new(name, version, platform, dependencies, metadata) } + subject(:spec) { described_class.new(name, version, platform, spec_fetcher, dependencies, metadata) } describe "#build_dependency" do let(:name) { "foo" } @@ -48,7 +49,9 @@ RSpec.describe Bundler::EndpointSpecification do end it "supports equality comparison" do - other_spec = described_class.new("bar", version, platform, dependencies, metadata) + remote_spec = double(:remote_spec, :required_ruby_version => nil, :required_rubygems_version => nil) + allow(spec_fetcher).to receive(:fetch_spec).and_return(remote_spec) + other_spec = described_class.new("bar", version, platform, spec_fetcher, dependencies, metadata) expect(spec).to eql(spec) expect(spec).to_not eql(other_spec) end diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb index 14b0069b6e..9e446ff267 100644 --- a/spec/bundler/commands/binstubs_spec.rb +++ b/spec/bundler/commands/binstubs_spec.rb @@ -182,7 +182,7 @@ RSpec.describe "bundle binstubs <gem>" do end context "and the version is older and the same major" do - let(:system_bundler_version) { "2.3.1" } + let(:system_bundler_version) { "2.3.3" } before do lockfile lockfile.gsub(/BUNDLED WITH\n .*$/m, "BUNDLED WITH\n 2.3.0") @@ -191,7 +191,7 @@ RSpec.describe "bundle binstubs <gem>" do it "installs and runs the exact version of bundler", :rubygems => ">= 3.3.0.dev" do sys_exec "bin/bundle install --verbose", :artifice => "vcr" expect(exitstatus).not_to eq(42) - 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("Bundler 2.3.3 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 @@ -199,8 +199,8 @@ RSpec.describe "bundle binstubs <gem>" do 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 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(out).not_to include("Bundler 2.3.3 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.3") expect(err).not_to include("Activating bundler (~> 2.3.0) failed:") end end diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index 3878c47799..ee5d53c527 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -1120,18 +1120,33 @@ 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 - expect(the_bundle).to include_gem "rack 1.0" + 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.locked_gems.bundler_version).to eq v(Bundler::VERSION) + expect(the_bundle).to include_gem "rack 1.0" end - it "updates the bundler version in the lockfile without re-resolving if the locked version is already installed" do + 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 @@ -1144,7 +1159,7 @@ RSpec.describe "bundle update --bundler" do G lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.3") - bundle :update, :bundler => true, :artifice => "vcr", :verbose => true + bundle :update, :bundler => true, :artifice => "compact_index", :verbose => true expect(out).to include("Using bundler #{Bundler::VERSION}") expect(lockfile).to eq <<~L @@ -1165,6 +1180,149 @@ RSpec.describe "bundle update --bundler" do 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 + + # 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 # these specs are slow and focus on integration and therefore are not exhaustive. unit specs elsewhere handle that. diff --git a/spec/bundler/install/gemfile/gemspec_spec.rb b/spec/bundler/install/gemfile/gemspec_spec.rb index 6d9cd2daff..e7cf8f08d2 100644 --- a/spec/bundler/install/gemfile/gemspec_spec.rb +++ b/spec/bundler/install/gemfile/gemspec_spec.rb @@ -179,7 +179,7 @@ RSpec.describe "bundle install from an existing gemspec" do gemspec :path => '#{tmp.join("foo")}' G - bundle "update --bundler", :verbose => true + bundle "update --bundler", :artifice => "compact_index", :verbose => true expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 JAVA" end diff --git a/spec/bundler/install/gems/dependency_api_spec.rb b/spec/bundler/install/gems/dependency_api_spec.rb index 9738a75474..79317a7fad 100644 --- a/spec/bundler/install/gems/dependency_api_spec.rb +++ b/spec/bundler/install/gems/dependency_api_spec.rb @@ -402,17 +402,6 @@ RSpec.describe "gemcutter's dependency API" do expect(the_bundle).to include_gems "back_deps 1.0" end - it "uses the endpoint if all sources support it" do - gemfile <<-G - source "#{source_uri}" - - gem 'foo' - G - - bundle :install, :artifice => "endpoint_api_missing" - expect(the_bundle).to include_gems "foo 1.0" - end - it "fetches again when more dependencies are found in subsequent sources using deployment mode", :bundler => "< 3" do build_repo2 do build_gem "back_deps" do |s| diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb index 4cf57f439e..b0209489b9 100644 --- a/spec/bundler/install/gems/resolving_spec.rb +++ b/spec/bundler/install/gems/resolving_spec.rb @@ -224,6 +224,27 @@ RSpec.describe "bundle install with install-time dependencies" do expect(the_bundle).to include_gems("rack 1.2") end + it "installs the older version when using servers not implementing the compact index API" do + build_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + + build_gem "rack", "9001.0.0" do |s| + s.required_ruby_version = "> 9000" + end + end + + install_gemfile <<-G, :artifice => "endpoint", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } + ruby "#{RUBY_VERSION}" + source "http://localgemserver.test/" + gem 'rack' + G + + expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000") + expect(the_bundle).to include_gems("rack 1.2") + end + it "installs the older version under rate limiting conditions" do build_repo4 do build_gem "rack", "9001.0.0" do |s| @@ -284,8 +305,6 @@ RSpec.describe "bundle install with install-time dependencies" do shared_examples_for "ruby version conflicts" do it "raises an error during resolution" do - skip "ruby requirement includes platform and it shouldn't" if Gem.win_platform? - install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }, :raise_on_error => false source "http://localgemserver.test/" ruby #{ruby_requirement} @@ -301,8 +320,6 @@ RSpec.describe "bundle install with install-time dependencies" do require_ruby was resolved to 1.0, which depends on Ruby\0 (> 9000) - - Ruby\0 (> 9000), which is required by gem 'require_ruby', is not available in the local ruby installation E expect(err).to end_with(nice_error) end @@ -341,7 +358,15 @@ RSpec.describe "bundle install with install-time dependencies" do G expect(err).to_not include("Gem::InstallError: require_rubygems requires RubyGems version > 9000") - expect(err).to include("require_rubygems-1.0 requires rubygems version > 9000, which is incompatible with the current version, #{Gem::VERSION}") + nice_error = strip_whitespace(<<-E).strip + Bundler found conflicting requirements for the RubyGems\0 version: + In Gemfile: + RubyGems\0 (= #{Gem::VERSION}) + + require_rubygems was resolved to 1.0, which depends on + RubyGems\0 (> 9000) + E + expect(err).to end_with(nice_error) end end end diff --git a/spec/bundler/support/artifice/endpoint_api_missing.rb b/spec/bundler/support/artifice/endpoint_api_missing.rb deleted file mode 100644 index 755c42e836..0000000000 --- a/spec/bundler/support/artifice/endpoint_api_missing.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require_relative "endpoint" - -Artifice.deactivate - -class EndpointApiMissing < Endpoint - get "/fetch/actual/gem/:id" do - warn params[:id] - if params[:id] == "rack-1.0.gemspec.rz" - halt 404 - else - File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}") - end - end -end - -Artifice.activate_with(EndpointApiMissing) |