diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-04-28 17:15:43 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-04-28 19:08:49 +0900 |
commit | 1056489ea3e1c3f201936666b2725bfc142bb0f2 (patch) | |
tree | cc993148b660f7cc2d92823ccfafcf10d3009c0a /spec | |
parent | cd2410f9d8c99fd0fbb232eb5f195188fbfc122f (diff) |
Merge https://github.com/rubygems/rubygems/commit/3f7d0352e84b29d4a2d4cd93b31e5ebdb5f79cc6
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5669
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/bundler/ruby_version_spec.rb | 26 | ||||
-rw-r--r-- | spec/bundler/commands/lock_spec.rb | 34 | ||||
-rw-r--r-- | spec/bundler/commands/update_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/install/gems/resolving_spec.rb | 37 | ||||
-rw-r--r-- | spec/bundler/install/gems/standalone_spec.rb | 2 |
5 files changed, 69 insertions, 34 deletions
diff --git a/spec/bundler/bundler/ruby_version_spec.rb b/spec/bundler/bundler/ruby_version_spec.rb index 8c6c071d7f..3e3850031c 100644 --- a/spec/bundler/bundler/ruby_version_spec.rb +++ b/spec/bundler/bundler/ruby_version_spec.rb @@ -498,31 +498,5 @@ RSpec.describe "Bundler::RubyVersion and its subclasses" do end end end - - describe "#to_gem_version_with_patchlevel" do - shared_examples_for "the patchlevel is omitted" do - it "does not include a patch level" do - expect(subject.to_gem_version_with_patchlevel.to_s).to eq(version) - end - end - - context "with nil patch number" do - let(:patchlevel) { nil } - - it_behaves_like "the patchlevel is omitted" - end - - context "with negative patch number" do - let(:patchlevel) { -1 } - - it_behaves_like "the patchlevel is omitted" - end - - context "with a valid patch number" do - it "uses the specified patchlevel as patchlevel" do - expect(subject.to_gem_version_with_patchlevel.to_s).to eq("#{version}.#{patchlevel}") - end - end - end end end diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb index ee1c3ffd46..9c5240157f 100644 --- a/spec/bundler/commands/lock_spec.rb +++ b/spec/bundler/commands/lock_spec.rb @@ -542,6 +542,40 @@ RSpec.describe "bundle lock" do bundle "lock --add-platform x86_64-linux", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } end + it "respects lower bound ruby requirements" do + skip "this spec does not work with prereleases because their version is actually lower than their reported `RUBY_VERSION`" if RUBY_PATCHLEVEL == -1 + + build_repo4 do + build_gem "our_private_gem", "0.1.0" do |s| + s.required_ruby_version = ">= #{RUBY_VERSION}" + end + end + + gemfile <<-G + source "https://localgemserver.test" + + gem "our_private_gem" + G + + lockfile <<-L + GEM + remote: https://localgemserver.test/ + specs: + our_private_gem (0.1.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + our_private_gem + + BUNDLED WITH + #{Bundler::VERSION} + L + + bundle "install", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + end + context "when an update is available" do let(:repo) { gem_repo2 } diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index d013d5bd73..d45a565475 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -1182,6 +1182,8 @@ RSpec.describe "bundle update --bundler" do end it "updates the bundler version in the lockfile even if the latest version is not installed", :ruby_repo, :realworld do + skip "ruby-head has a default Bundler version too high for this spec to work" if RUBY_PATCHLEVEL == -1 + pristine_system_gems "bundler-2.3.9" build_repo4 do @@ -1226,6 +1228,8 @@ RSpec.describe "bundle update --bundler" do end it "errors if the explicit target version does not exist", :realworld do + skip "ruby-head has a default Bundler version too high for this spec to work" if RUBY_PATCHLEVEL == -1 + pristine_system_gems "bundler-2.3.9" build_repo4 do diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb index 209996f61f..83f1e60806 100644 --- a/spec/bundler/install/gems/resolving_spec.rb +++ b/spec/bundler/install/gems/resolving_spec.rb @@ -301,7 +301,28 @@ RSpec.describe "bundle install with install-time dependencies" do end let(:ruby_requirement) { %("#{RUBY_VERSION}") } - let(:error_message_requirement) { "~> #{RUBY_VERSION}.0" } + let(:error_message_requirement) { "= #{RUBY_VERSION}" } + + it "raises a proper error that mentions the current Ruby version during resolution" do + install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }, :raise_on_error => false + source "http://localgemserver.test/" + gem 'require_ruby' + G + + expect(out).to_not include("Gem::InstallError: require_ruby requires Ruby version > 9000") + + nice_error = strip_whitespace(<<-E).strip + Bundler found conflicting requirements for the Ruby\0 version: + In Gemfile: + require_ruby was resolved to 1.0, which depends on + Ruby\0 (> 9000) + + Current Ruby\0 version: + Ruby\0 (#{error_message_requirement}) + + E + expect(err).to end_with(nice_error) + end shared_examples_for "ruby version conflicts" do it "raises an error during resolution" do @@ -316,10 +337,12 @@ RSpec.describe "bundle install with install-time dependencies" do nice_error = strip_whitespace(<<-E).strip Bundler found conflicting requirements for the Ruby\0 version: In Gemfile: - Ruby\0 (#{error_message_requirement}) - require_ruby was resolved to 1.0, which depends on Ruby\0 (> 9000) + + Current Ruby\0 version: + Ruby\0 (#{error_message_requirement}) + E expect(err).to end_with(nice_error) end @@ -329,7 +352,6 @@ RSpec.describe "bundle install with install-time dependencies" do describe "with a < requirement" do let(:ruby_requirement) { %("< 5000") } - let(:error_message_requirement) { "< 5000" } it_behaves_like "ruby version conflicts" end @@ -337,7 +359,6 @@ RSpec.describe "bundle install with install-time dependencies" do describe "with a compound requirement" do let(:reqs) { ["> 0.1", "< 5000"] } let(:ruby_requirement) { reqs.map(&:dump).join(", ") } - let(:error_message_requirement) { Gem::Requirement.new(reqs).to_s } it_behaves_like "ruby version conflicts" end @@ -361,10 +382,12 @@ RSpec.describe "bundle install with install-time dependencies" do 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) + + Current RubyGems\0 version: + RubyGems\0 (= #{Gem::VERSION}) + E expect(err).to end_with(nice_error) end diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb index 66dd7f534a..5cbb484c68 100644 --- a/spec/bundler/install/gems/standalone_spec.rb +++ b/spec/bundler/install/gems/standalone_spec.rb @@ -120,7 +120,7 @@ RSpec.shared_examples "bundle install --standalone" do realworld_system_gems "tsort --version 0.1.0" - necessary_system_gems = ["optparse --version 0.1.1", "psych --version 3.3.2", "logger --version 1.4.3", "etc --version 1.2.0", "stringio --version 3.0.0"] + necessary_system_gems = ["optparse --version 0.1.1", "psych --version 3.3.2", "logger --version 1.4.3", "etc --version 1.2.0", "stringio --version 3.0.1"] necessary_system_gems += ["shellwords --version 0.1.0", "base64 --version 0.1.0", "resolv --version 0.2.1"] if Gem.rubygems_version < Gem::Version.new("3.3.a") necessary_system_gems += ["yaml --version 0.1.1"] if Gem.rubygems_version < Gem::Version.new("3.4.a") realworld_system_gems(*necessary_system_gems, :path => scoped_gem_path(bundled_app("bundle"))) |