diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-01-21 14:35:56 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-21 14:35:56 +0900 |
commit | 151e469a6259837246d88b3abbb4d9e46ff38b9d (patch) | |
tree | c071c3e89e5d9ce493f754ce0536499373eab286 /spec/bundler | |
parent | 41d0c708122d0f6389410d503b7f4e6342bf56a0 (diff) |
Merge RubyGems 3.2.6 and Bundler 2.2.6 (#4103)
Diffstat (limited to 'spec/bundler')
-rw-r--r-- | spec/bundler/bundler/dep_proxy_spec.rb | 22 | ||||
-rw-r--r-- | spec/bundler/bundler/gem_version_promoter_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/install/gemfile/path_spec.rb | 65 | ||||
-rw-r--r-- | spec/bundler/install/gems/resolving_spec.rb | 8 | ||||
-rw-r--r-- | spec/bundler/realworld/slow_perf_spec.rb | 20 | ||||
-rw-r--r-- | spec/bundler/resolver/basic_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/support/indexes.rb | 2 |
7 files changed, 108 insertions, 13 deletions
diff --git a/spec/bundler/bundler/dep_proxy_spec.rb b/spec/bundler/bundler/dep_proxy_spec.rb index 0f8d6b1076..84243d2ee2 100644 --- a/spec/bundler/bundler/dep_proxy_spec.rb +++ b/spec/bundler/bundler/dep_proxy_spec.rb @@ -2,10 +2,10 @@ RSpec.describe Bundler::DepProxy do let(:dep) { Bundler::Dependency.new("rake", ">= 0") } - subject { described_class.new(dep, Gem::Platform::RUBY) } + subject { described_class.get_proxy(dep, Gem::Platform::RUBY) } let(:same) { subject } - let(:other) { subject.dup } - let(:different) { described_class.new(dep, Gem::Platform::JAVA) } + let(:other) { described_class.get_proxy(dep, Gem::Platform::RUBY) } + let(:different) { described_class.get_proxy(dep, Gem::Platform::JAVA) } describe "#eql?" do it { expect(subject.eql?(same)).to be true } @@ -15,8 +15,18 @@ RSpec.describe Bundler::DepProxy do it { expect(subject.eql?("foobar")).to be false } end - describe "#hash" do - it { expect(subject.hash).to eq(same.hash) } - it { expect(subject.hash).to eq(other.hash) } + describe "must use factory methods" do + it { expect { described_class.new(dep, Gem::Platform::RUBY) }.to raise_error NoMethodError } + it { expect { subject.dup }.to raise_error NoMethodError } + it { expect { subject.clone }.to raise_error NoMethodError } + end + + describe "frozen" do + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.5.0") + error = Object.const_get("FrozenError") + else + error = RuntimeError + end + it { expect { subject.instance_variable_set(:@__platform, {}) }.to raise_error error } end end diff --git a/spec/bundler/bundler/gem_version_promoter_spec.rb b/spec/bundler/bundler/gem_version_promoter_spec.rb index 01e0232fba..af51a270b6 100644 --- a/spec/bundler/bundler/gem_version_promoter_spec.rb +++ b/spec/bundler/bundler/gem_version_promoter_spec.rb @@ -170,7 +170,7 @@ RSpec.describe Bundler::GemVersionPromoter do context "debug output" do it "should not kerblooie on its own debug output" do gvp = unlocking(:level => :patch) - dep = Bundler::DepProxy.new(dep("foo", "1.2.0").first, "ruby") + dep = Bundler::DepProxy.get_proxy(dep("foo", "1.2.0").first, "ruby") result = gvp.send(:debug_format_result, dep, build_spec_groups("foo", %w[1.2.0 1.3.0])) expect(result.class).to eq Array end diff --git a/spec/bundler/install/gemfile/path_spec.rb b/spec/bundler/install/gemfile/path_spec.rb index f19fe39721..6cd981e3d3 100644 --- a/spec/bundler/install/gemfile/path_spec.rb +++ b/spec/bundler/install/gemfile/path_spec.rb @@ -581,6 +581,71 @@ RSpec.describe "bundle install with explicit source paths" do expect(the_bundle).to include_gems "rack 0.9.1" end + + it "keeps using the same version even when another dependency is added" do + build_lib "foo", "1.0", :path => lib_path("foo") do |s| + s.add_dependency "rack", "0.9.1" + end + + bundle "install" + + expect(the_bundle).to include_gems "rack 0.9.1" + + lockfile_should_be <<-G + PATH + remote: #{lib_path("foo")} + specs: + foo (1.0) + rack (= 0.9.1) + + GEM + remote: #{file_uri_for(gem_repo1)}/ + specs: + rack (0.9.1) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + foo! + + BUNDLED WITH + #{Bundler::VERSION} + G + + build_lib "foo", "1.0", :path => lib_path("foo") do |s| + s.add_dependency "rack" + s.add_dependency "rake", "13.0.1" + end + + bundle "install" + + lockfile_should_be <<-G + PATH + remote: #{lib_path("foo")} + specs: + foo (1.0) + rack + rake (= 13.0.1) + + GEM + remote: #{file_uri_for(gem_repo1)}/ + specs: + rack (0.9.1) + rake (13.0.1) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + foo! + + BUNDLED WITH + #{Bundler::VERSION} + G + + expect(the_bundle).to include_gems "rack 0.9.1" + end end describe "switching sources" do diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb index d4cccbe051..8ea61afca2 100644 --- a/spec/bundler/install/gems/resolving_spec.rb +++ b/spec/bundler/install/gems/resolving_spec.rb @@ -88,7 +88,7 @@ RSpec.describe "bundle install with install-time dependencies" do end it "installs plugins depended on by other plugins" do - install_gemfile <<-G + install_gemfile <<-G, :env => { "DEBUG" => "1" } source "#{file_uri_for(gem_repo2)}" gem "net_a" G @@ -97,7 +97,7 @@ RSpec.describe "bundle install with install-time dependencies" do end it "installs multiple levels of dependencies" do - install_gemfile <<-G + install_gemfile <<-G, :env => { "DEBUG" => "1" } source "#{file_uri_for(gem_repo2)}" gem "net_c" gem "net_e" @@ -114,7 +114,7 @@ RSpec.describe "bundle install with install-time dependencies" do gem "net_e" G - bundle :install, :env => { "BUNDLER_DEBUG_RESOLVER" => "1" } + bundle :install, :env => { "BUNDLER_DEBUG_RESOLVER" => "1", "DEBUG" => "1" } expect(out).to include("BUNDLER: Starting resolution") end @@ -128,7 +128,7 @@ RSpec.describe "bundle install with install-time dependencies" do gem "net_e" G - bundle :install, :env => { "DEBUG_RESOLVER" => "1" } + bundle :install, :env => { "DEBUG_RESOLVER" => "1", "DEBUG" => "1" } expect(out).to include("BUNDLER: Starting resolution") end diff --git a/spec/bundler/realworld/slow_perf_spec.rb b/spec/bundler/realworld/slow_perf_spec.rb new file mode 100644 index 0000000000..518da2800b --- /dev/null +++ b/spec/bundler/realworld/slow_perf_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require "spec_helper" + +RSpec.describe "bundle install with complex dependencies", :realworld => true do + it "resolves quickly" do + start_time = Time.now + + install_gemfile <<-G + source 'https://rubygems.org' + + gem "actionmailer" + gem "mongoid", ">= 0.10.2" + G + + duration = Time.now - start_time + + expect(duration.to_f).to be < 120 # seconds + end +end diff --git a/spec/bundler/resolver/basic_spec.rb b/spec/bundler/resolver/basic_spec.rb index 57897f89b4..ee62dc3577 100644 --- a/spec/bundler/resolver/basic_spec.rb +++ b/spec/bundler/resolver/basic_spec.rb @@ -176,7 +176,7 @@ Bundler could not find compatible versions for gem "a": deps = [] @deps.each do |d| - deps << Bundler::DepProxy.new(d, "ruby") + deps << Bundler::DepProxy.get_proxy(d, "ruby") end should_resolve_and_include %w[foo-1.0.0 bar-1.0.0], [[]] diff --git a/spec/bundler/support/indexes.rb b/spec/bundler/support/indexes.rb index 7440523fc9..45b68541f5 100644 --- a/spec/bundler/support/indexes.rb +++ b/spec/bundler/support/indexes.rb @@ -22,7 +22,7 @@ module Spec @deps.each do |d| @platforms.each do |p| source_requirements[d.name] = d.source = default_source - deps << Bundler::DepProxy.new(d, p) + deps << Bundler::DepProxy.get_proxy(d, p) end end source_requirements ||= {} |