From 93dcf0828dc8e627e0c24497795d927911a9d993 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 14 Jan 2021 13:38:17 +0900 Subject: Merge Bundler-2.2.5 --- .../bundler/compact_index_client/updater_spec.rb | 4 +- spec/bundler/bundler/gem_helper_spec.rb | 10 +++ spec/bundler/bundler/source/git/git_proxy_spec.rb | 8 ++- spec/bundler/bundler/source/git_spec.rb | 4 +- spec/bundler/commands/install_spec.rb | 29 +++++++- spec/bundler/commands/newgem_spec.rb | 8 +-- spec/bundler/install/deploy_spec.rb | 6 +- spec/bundler/install/gems/resolving_spec.rb | 17 +++-- spec/bundler/install/git_spec.rb | 21 ++++-- spec/bundler/lock/lockfile_spec.rb | 2 +- spec/bundler/realworld/edgecases_spec.rb | 30 +++++++- spec/bundler/runtime/setup_spec.rb | 79 ++++++++++++++-------- spec/bundler/support/builders.rb | 2 + 13 files changed, 158 insertions(+), 62 deletions(-) (limited to 'spec') diff --git a/spec/bundler/bundler/compact_index_client/updater_spec.rb b/spec/bundler/bundler/compact_index_client/updater_spec.rb index acb312edb3..d8bb15df7e 100644 --- a/spec/bundler/bundler/compact_index_client/updater_spec.rb +++ b/spec/bundler/bundler/compact_index_client/updater_spec.rb @@ -17,7 +17,6 @@ RSpec.describe Bundler::CompactIndexClient::Updater do let(:response) { double(:response, :body => "abc123") } it "treats the response as an update" do - expect(response).to receive(:[]).with("Content-Encoding") { "" } expect(response).to receive(:[]).with("ETag") { nil } expect(fetcher).to receive(:call) { response } @@ -29,8 +28,7 @@ RSpec.describe Bundler::CompactIndexClient::Updater do let(:response) { double(:response, :body => "") } it "raises HTTPError" do - expect(response).to receive(:[]).with("Content-Encoding") { "gzip" } - expect(fetcher).to receive(:call) { response } + expect(fetcher).to receive(:call).and_raise(Zlib::GzipFile::Error) expect do updater.update(local_path, remote_path) diff --git a/spec/bundler/bundler/gem_helper_spec.rb b/spec/bundler/bundler/gem_helper_spec.rb index 48af7867b4..30befdf40c 100644 --- a/spec/bundler/bundler/gem_helper_spec.rb +++ b/spec/bundler/bundler/gem_helper_spec.rb @@ -256,6 +256,16 @@ RSpec.describe Bundler::GemHelper do Rake.application["release"].invoke end + + it "also works when releasing from an ambiguous reference" do + # Create a branch with the same name as the tag + sys_exec("git checkout -b v#{app_version}", :dir => app_path) + sys_exec("git push -u origin v#{app_version}", :dir => app_path) + + expect(subject).to receive(:rubygem_push).with(app_gem_path.to_s) + + Rake.application["release"].invoke + end end context "on releasing with a custom tag prefix" do diff --git a/spec/bundler/bundler/source/git/git_proxy_spec.rb b/spec/bundler/bundler/source/git/git_proxy_spec.rb index 35702d7763..97f06973cb 100644 --- a/spec/bundler/bundler/source/git/git_proxy_spec.rb +++ b/spec/bundler/bundler/source/git/git_proxy_spec.rb @@ -130,18 +130,20 @@ RSpec.describe Bundler::Source::Git::GitProxy do context "when given a SHA as a revision" do let(:revision) { "abcd" * 10 } let(:command) { ["reset", "--hard", revision] } + let(:command_for_display) { "git #{command.shelljoin}" } it "fails gracefully when resetting to the revision fails" do expect(subject).to receive(:git_retry).with("clone", any_args) { destination.mkpath } expect(subject).to receive(:git_retry).with("fetch", any_args, :dir => destination) - expect(subject).to receive(:git).with(*command, :dir => destination).and_raise(Bundler::Source::Git::GitCommandError.new(command, cache, destination)) + expect(subject).to receive(:git).with(*command, :dir => destination).and_raise(Bundler::Source::Git::GitCommandError.new(command_for_display, destination)) expect(subject).not_to receive(:git) expect { subject.copy_to(destination, submodules) }. to raise_error( Bundler::Source::Git::MissingGitRevisionError, - "Git error: command `git #{command}` in directory #{destination} has failed.\n" \ - "Revision #{revision} does not exist in the repository #{uri}. Maybe you misspelled it?" \ + "Git error: command `#{command_for_display}` in directory #{destination} has failed.\n" \ + "Revision #{revision} does not exist in the repository #{uri}. Maybe you misspelled it?\n" \ + "If this error persists you could try removing the cache directory '#{destination}'" ) end end diff --git a/spec/bundler/bundler/source/git_spec.rb b/spec/bundler/bundler/source/git_spec.rb index f7475a35aa..6668b6e69a 100644 --- a/spec/bundler/bundler/source/git_spec.rb +++ b/spec/bundler/bundler/source/git_spec.rb @@ -14,14 +14,14 @@ RSpec.describe Bundler::Source::Git do describe "#to_s" do it "returns a description" do - expect(subject.to_s).to eq "https://github.com/foo/bar.git (at master)" + expect(subject.to_s).to eq "https://github.com/foo/bar.git" end context "when the URI contains credentials" do let(:uri) { "https://my-secret-token:x-oauth-basic@github.com/foo/bar.git" } it "filters credentials" do - expect(subject.to_s).to eq "https://x-oauth-basic@github.com/foo/bar.git (at master)" + expect(subject.to_s).to eq "https://x-oauth-basic@github.com/foo/bar.git" end end end diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index 043805df79..f12d32d6a8 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -580,8 +580,31 @@ RSpec.describe "bundle install with gem sources" do end describe "when bundle path does not have write access", :permissions do + let(:bundle_path) { bundled_app("vendor") } + + before do + FileUtils.mkdir_p(bundle_path) + gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + gem 'rack' + G + end + + it "should display a proper message to explain the problem" do + FileUtils.chmod(0o500, bundle_path) + + bundle "config set --local path vendor" + bundle :install, :raise_on_error => false + expect(err).to include(bundle_path.to_s) + expect(err).to include("grant write permissions") + end + end + + describe "when bundle cache path does not have write access", :permissions do + let(:cache_path) { bundled_app("vendor/#{Bundler.ruby_scope}/cache") } + before do - FileUtils.mkdir_p(bundled_app("vendor")) + FileUtils.mkdir_p(cache_path) gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem 'rack' @@ -589,11 +612,11 @@ RSpec.describe "bundle install with gem sources" do end it "should display a proper message to explain the problem" do - FileUtils.chmod(0o500, bundled_app("vendor")) + FileUtils.chmod(0o500, cache_path) bundle "config --local path vendor" bundle :install, :raise_on_error => false - expect(err).to include(bundled_app("vendor").to_s) + expect(err).to include(cache_path.to_s) expect(err).to include("grant write permissions") end end diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb index 421ffa80c6..265268a1fe 100644 --- a/spec/bundler/commands/newgem_spec.rb +++ b/spec/bundler/commands/newgem_spec.rb @@ -12,10 +12,10 @@ RSpec.describe "bundle gem" do def bundle_exec_rubocop prepare_gemspec(bundled_app(gem_name, "#{gem_name}.gemspec")) - rubocop_version = RUBY_VERSION > "2.4" ? "0.90.0" : "0.80.1" + rubocop_version = RUBY_VERSION > "2.4" ? "1.7.0" : "0.81.0" gems = ["minitest", "rake", "rake-compiler", "rspec", "rubocop -v #{rubocop_version}", "test-unit"] gems.unshift "parallel -v 1.19.2" if RUBY_VERSION < "2.5" - gems += ["rubocop-ast -v 0.4.0"] if rubocop_version == "0.90.0" + gems += ["rubocop-ast -v 1.4.0"] if rubocop_version == "1.7.0" path = Bundler.feature_flag.default_install_uses_path? ? local_gem_path(:base => bundled_app(gem_name)) : system_gem_path realworld_system_gems gems, :path => path bundle "exec rubocop --debug --config .rubocop.yml", :dir => bundled_app(gem_name) @@ -416,9 +416,7 @@ RSpec.describe "bundle gem" do it "sets a minimum ruby version" do bundle "gem #{gem_name}" - bundler_gemspec = Bundler::GemHelper.new(gemspec_dir).gemspec - - expect(bundler_gemspec.required_ruby_version).to eq(generated_gemspec.required_ruby_version) + expect(generated_gemspec.required_ruby_version).to eq(Gem::Requirement.new(Gem.ruby_version < Gem::Version.new("2.4.a") ? ">= 2.3.0" : ">= 2.4.0")) end it "requires the version file" do diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb index 357f4512f1..73a0c18f4a 100644 --- a/spec/bundler/install/deploy_spec.rb +++ b/spec/bundler/install/deploy_spec.rb @@ -341,7 +341,7 @@ RSpec.describe "install in deployment or frozen mode" do bundle "config --local deployment true" bundle :install, :raise_on_error => false expect(err).to include("deployment mode") - expect(err).to include("You have added to the Gemfile:\n* source: git://hubz.com (at master)") + expect(err).to include("You have added to the Gemfile:\n* source: git://hubz.com") expect(err).not_to include("You have changed in the Gemfile") end @@ -361,7 +361,7 @@ RSpec.describe "install in deployment or frozen mode" do bundle "config --local deployment true" bundle :install, :raise_on_error => false expect(err).to include("deployment mode") - expect(err).to include("You have deleted from the Gemfile:\n* source: #{lib_path("rack-1.0")} (at master@#{revision_for(lib_path("rack-1.0"))[0..6]}") + expect(err).to include("You have deleted from the Gemfile:\n* source: #{lib_path("rack-1.0")}") expect(err).not_to include("You have added to the Gemfile") expect(err).not_to include("You have changed in the Gemfile") end @@ -385,7 +385,7 @@ RSpec.describe "install in deployment or frozen mode" do bundle "config --local deployment true" bundle :install, :raise_on_error => false expect(err).to include("deployment mode") - expect(err).to include("You have changed in the Gemfile:\n* rack from `no specified source` to `#{lib_path("rack")} (at master@#{revision_for(lib_path("rack"))[0..6]})`") + expect(err).to include("You have changed in the Gemfile:\n* rack from `no specified source` to `#{lib_path("rack")}`") expect(err).not_to include("You have added to the Gemfile") expect(err).not_to include("You have deleted from the Gemfile") end diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb index 4384a731cd..d4cccbe051 100644 --- a/spec/bundler/install/gems/resolving_spec.rb +++ b/spec/bundler/install/gems/resolving_spec.rb @@ -142,10 +142,13 @@ RSpec.describe "bundle install with install-time dependencies" do gem "net_e" G - bundle :install, :env => { "DEBUG_RESOLVER_TREE" => "1" } + bundle :install, :env => { "DEBUG_RESOLVER_TREE" => "1", "DEBUG" => "1" } - activated_groups = "net_b (1.0) (ruby)" - activated_groups += ", net_b (1.0) (#{local_platforms.join(", ")})" if local_platforms.any? && local_platforms != ["ruby"] + activated_groups = if local_platforms.any? + "net_b (1.0) (#{local_platforms.join(", ")})" + else + "net_b (1.0) (ruby)" + end expect(out).to include(" net_b"). and include("BUNDLER: Starting resolution"). @@ -239,7 +242,7 @@ RSpec.describe "bundle install with install-time dependencies" do let(:ruby_requirement) { %("#{RUBY_VERSION}") } let(:error_message_requirement) { "~> #{RUBY_VERSION}.0" } - let(:error_message_platform) { " #{Bundler.local_platform}" } + let(:error_message_platform) { Bundler.local_platform } shared_examples_for "ruby version conflicts" do it "raises an error during resolution" do @@ -256,10 +259,10 @@ 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})#{error_message_platform} + Ruby\0 (#{error_message_requirement}) #{error_message_platform} - require_ruby#{error_message_platform} was resolved to 1.0, which depends on - Ruby\0 (> 9000) + require_ruby #{error_message_platform} was resolved to 1.0, which depends on + Ruby\0 (> 9000) #{error_message_platform} Ruby\0 (> 9000), which is required by gem 'require_ruby', is not available in the local ruby installation E diff --git a/spec/bundler/install/git_spec.rb b/spec/bundler/install/git_spec.rb index 62658137e0..61eaee4a84 100644 --- a/spec/bundler/install/git_spec.rb +++ b/spec/bundler/install/git_spec.rb @@ -2,10 +2,10 @@ RSpec.describe "bundle install" do context "git sources" do - it "displays the revision hash of the gem repository", :bundler => "< 3" do + it "displays the revision hash of the gem repository" do build_git "foo", "1.0", :path => lib_path("foo") - install_gemfile <<-G + install_gemfile <<-G, :verbose => true gem "foo", :git => "#{file_uri_for(lib_path("foo"))}" G @@ -13,7 +13,18 @@ RSpec.describe "bundle install" do expect(the_bundle).to include_gems "foo 1.0", :source => "git@#{lib_path("foo")}" end - it "displays the ref of the gem repository when using branch~num as a ref", :bundler => "< 3" do + it "displays the correct default branch" do + build_git "foo", "1.0", :path => lib_path("foo"), :default_branch => "main" + + install_gemfile <<-G, :verbose => true + gem "foo", :git => "#{file_uri_for(lib_path("foo"))}" + G + + expect(out).to include("Using foo 1.0 from #{file_uri_for(lib_path("foo"))} (at main@#{revision_for(lib_path("foo"))[0..6]})") + expect(the_bundle).to include_gems "foo 1.0", :source => "git@#{lib_path("foo")}" + end + + it "displays the ref of the gem repository when using branch~num as a ref" do skip "maybe branch~num notation doesn't work on Windows' git" if Gem.win_platform? build_git "foo", "1.0", :path => lib_path("foo") @@ -22,7 +33,7 @@ RSpec.describe "bundle install" do rev2 = revision_for(lib_path("foo"))[0..6] update_git "foo", "3.0", :path => lib_path("foo"), :gemspec => true - install_gemfile <<-G + install_gemfile <<-G, :verbose => true gem "foo", :git => "#{file_uri_for(lib_path("foo"))}", :ref => "master~2" G @@ -31,7 +42,7 @@ RSpec.describe "bundle install" do update_git "foo", "4.0", :path => lib_path("foo"), :gemspec => true - bundle :update, :all => true + bundle :update, :all => true, :verbose => true expect(out).to include("Using foo 2.0 (was 1.0) from #{file_uri_for(lib_path("foo"))} (at master~2@#{rev2})") expect(the_bundle).to include_gems "foo 2.0", :source => "git@#{lib_path("foo")}" end diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb index 0d340b070e..d3591cd62a 100644 --- a/spec/bundler/lock/lockfile_spec.rb +++ b/spec/bundler/lock/lockfile_spec.rb @@ -1134,7 +1134,7 @@ RSpec.describe "the lockfile format" do G expect(bundled_app_lock).not_to exist - expect(err).to include "rack (>= 0) should come from an unspecified source and git://hubz.com (at master)" + expect(err).to include "rack (>= 0) should come from an unspecified source and git://hubz.com" end it "works correctly with multiple version dependencies" do diff --git a/spec/bundler/realworld/edgecases_spec.rb b/spec/bundler/realworld/edgecases_spec.rb index 0f19cc7842..eb38613742 100644 --- a/spec/bundler/realworld/edgecases_spec.rb +++ b/spec/bundler/realworld/edgecases_spec.rb @@ -451,9 +451,35 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do bundle :lock, :env => { "DEBUG_RESOLVER" => "1" } if Bundler.feature_flag.bundler_3_mode? - expect(out).to include("BUNDLER: Finished resolution (2492 steps)") + expect(out).to include("BUNDLER: Finished resolution (1336 steps)") else - expect(out).to include("BUNDLER: Finished resolution (2722 steps)") + expect(out).to include("BUNDLER: Finished resolution (1395 steps)") + end + end + + it "doesn't hang on tricky gemfile" do + skip "Only for ruby 2.7.2" if RUBY_VERSION != "2.7.2" + + gemfile <<~G + source 'https://rubygems.org' + + group :development do + gem "puppet-module-posix-default-r2.7", '~> 0.3' + gem "puppet-module-posix-dev-r2.7", '~> 0.3' + gem "beaker-rspec" + gem "beaker-puppet" + gem "beaker-docker" + gem "beaker-puppet_install_helper" + gem "beaker-module_install_helper" + end + G + + bundle :lock, :env => { "DEBUG_RESOLVER" => "1" } + + if Bundler.feature_flag.bundler_3_mode? + expect(out).to include("BUNDLER: Finished resolution (366 steps)") + else + expect(out).to include("BUNDLER: Finished resolution (372 steps)") end end end diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index ead826c4e6..7b15a9b644 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -12,7 +12,7 @@ RSpec.describe "Bundler.setup" do G ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup require 'rack' @@ -34,7 +34,7 @@ RSpec.describe "Bundler.setup" do it "doesn't make all groups available" do ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup(:default) begin @@ -49,7 +49,7 @@ RSpec.describe "Bundler.setup" do it "accepts string for group name" do ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup(:default, 'test') require 'rack' @@ -61,7 +61,7 @@ RSpec.describe "Bundler.setup" do it "leaves all groups available if they were already" do ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup Bundler.setup(:default) @@ -74,7 +74,7 @@ RSpec.describe "Bundler.setup" do it "leaves :default available if setup is called twice" do ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup(:default) Bundler.setup(:default, :test) @@ -91,7 +91,7 @@ RSpec.describe "Bundler.setup" do it "handles multiple non-additive invocations" do ruby <<-RUBY, :raise_on_error => false - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup(:default, :test) Bundler.setup(:default) require 'rack' @@ -122,7 +122,7 @@ RSpec.describe "Bundler.setup" do ENV["RUBYLIB"] = "rubylib_dir" ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup puts $LOAD_PATH RUBY @@ -143,6 +143,10 @@ RSpec.describe "Bundler.setup" do gem "rails" G + # We require an absolute path because relying on the $LOAD_PATH behaves + # inconsistently depending on whether we're in a ruby-core setup (and + # bundler's lib is in RUBYLIB) or not. + ruby <<-RUBY require '#{lib_dir}/bundler' Bundler.setup @@ -171,6 +175,10 @@ RSpec.describe "Bundler.setup" do gem "terranova" G + # We require an absolute path because relying on the $LOAD_PATH behaves + # inconsistently depending on whether we're in a ruby-core setup (and + # bundler's lib is in RUBYLIB) or not. + ruby <<-RUBY require '#{lib_dir}/bundler/setup' puts $LOAD_PATH @@ -192,8 +200,10 @@ RSpec.describe "Bundler.setup" do gem "rack" G + entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler" : "bundler" + ruby <<-R - require '#{lib_dir}/bundler' + require '#{entrypoint}' begin Bundler.setup @@ -213,7 +223,7 @@ RSpec.describe "Bundler.setup" do G ruby <<-R, :raise_on_error => false - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup R @@ -236,7 +246,7 @@ RSpec.describe "Bundler.setup" do G ruby <<-R, :raise_on_error => false - require '#{lib_dir}/bundler' + require 'bundler' Bundler.setup R @@ -289,7 +299,7 @@ RSpec.describe "Bundler.setup" do ENV["BUNDLE_GEMFILE"] = "Gemfile" ruby <<-R - require '#{lib_dir}/bundler' + require 'bundler' begin Bundler.setup @@ -444,7 +454,7 @@ RSpec.describe "Bundler.setup" do break_git! ruby <<-R - require '#{lib_dir}/bundler' + require 'bundler' begin Bundler.setup @@ -464,8 +474,10 @@ RSpec.describe "Bundler.setup" do break_git! + entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler" : "bundler" + ruby <<-R - require "#{lib_dir}/bundler" + require "#{entrypoint}" begin Bundler.setup @@ -798,7 +810,7 @@ end # Don't build extensions. s.class.send(:define_method, :build_extensions) { nil } - require '#{lib_dir}/bundler' + require 'bundler' gem '#{gem_name}' puts $LOAD_PATH.count {|path| path =~ /#{gem_name}/} >= 2 @@ -1056,7 +1068,7 @@ end bundle "install" ruby <<-RUBY - require '#{lib_dir}/bundler' + require 'bundler' bundler_module = class << Bundler; self; end bundler_module.send(:remove_method, :require) def Bundler.require(path) @@ -1104,6 +1116,8 @@ end end before do + bundle "config set --local path.system true" + install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -1112,8 +1126,9 @@ end context "is not present" do it "does not change the lock" do + entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler/setup" : "bundler/setup" lockfile lock_with(nil) - ruby "require '#{lib_dir}/bundler/setup'" + ruby "require '#{entrypoint}'" lockfile_should_be lock_with(nil) end end @@ -1121,7 +1136,7 @@ end context "is newer" do it "does not change the lock or warn" do lockfile lock_with(Bundler::VERSION.succ) - ruby "require '#{lib_dir}/bundler/setup'" + ruby "require 'bundler/setup'" expect(out).to be_empty expect(err).to be_empty lockfile_should_be lock_with(Bundler::VERSION.succ) @@ -1130,8 +1145,10 @@ end context "is older" do it "does not change the lock" do + entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler/setup" : "bundler/setup" + system_gems "bundler-1.10.1" lockfile lock_with("1.10.1") - ruby "require '#{lib_dir}/bundler/setup'" + ruby "require '#{entrypoint}'" lockfile_should_be lock_with("1.10.1") end end @@ -1178,14 +1195,14 @@ end context "is not present" do it "does not change the lock" do - expect { ruby "require '#{lib_dir}/bundler/setup'" }.not_to change { lockfile } + expect { ruby "require 'bundler/setup'" }.not_to change { lockfile } end end context "is newer" do let(:ruby_version) { "5.5.5" } it "does not change the lock or warn" do - expect { ruby "require '#{lib_dir}/bundler/setup'" }.not_to change { lockfile } + expect { ruby "require 'bundler/setup'" }.not_to change { lockfile } expect(out).to be_empty expect(err).to be_empty end @@ -1194,7 +1211,7 @@ end context "is older" do let(:ruby_version) { "1.0.0" } it "does not change the lock" do - expect { ruby "require '#{lib_dir}/bundler/setup'" }.not_to change { lockfile } + expect { ruby "require 'bundler/setup'" }.not_to change { lockfile } end end end @@ -1202,8 +1219,9 @@ end describe "with gemified standard libraries" do it "does not load Psych" do gemfile "" + entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler/setup" : "bundler/setup" ruby <<-RUBY - require '#{lib_dir}/bundler/setup' + require '#{entrypoint}' puts defined?(Psych::VERSION) ? Psych::VERSION : "undefined" require 'psych' puts Psych::VERSION @@ -1216,7 +1234,7 @@ end it "does not load openssl" do install_gemfile "" ruby <<-RUBY - require "#{lib_dir}/bundler/setup" + require "bundler/setup" puts defined?(OpenSSL) || "undefined" require "openssl" puts defined?(OpenSSL) || "undefined" @@ -1274,7 +1292,7 @@ end it "activates no gems with -rbundler/setup" do install_gemfile "" - ruby code, :env => { "RUBYOPT" => activation_warning_hack_rubyopt + " -r#{lib_dir}/bundler/setup" } + ruby code, :env => { "RUBYOPT" => activation_warning_hack_rubyopt + " -rbundler/setup" } expect(out).to eq("{}") end @@ -1327,7 +1345,7 @@ end if File.exist?(ext_folder.join("#{require_name}.rb")) { :exclude_from_load_path => ext_folder.to_s } else - lib_folder = source_root.join("lib") + lib_folder = source_lib_dir if File.exist?(lib_folder.join("#{require_name}.rb")) { :exclude_from_load_path => lib_folder.to_s } else @@ -1383,7 +1401,7 @@ end G ruby <<-RUBY - require "#{lib_dir}/bundler/setup" + require "bundler/setup" Object.new.gem "rack" puts Gem.loaded_specs["rack"].full_name RUBY @@ -1398,7 +1416,7 @@ end G ruby <<-RUBY, :raise_on_error => false - require "#{lib_dir}/bundler/setup" + require "bundler/setup" Object.new.gem "rack" puts "FAIL" RUBY @@ -1414,7 +1432,7 @@ end G ruby <<-RUBY, :raise_on_error => false - require "#{lib_dir}/bundler/setup" + require "bundler/setup" Object.new.require "rack" puts "FAIL" RUBY @@ -1429,4 +1447,9 @@ end expect(last_command.stdboth).to eq("true") end end + + # Tested rubygems does not include https://github.com/rubygems/rubygems/pull/2728 and will not always end up activating the current bundler + def mis_activates_prerelease_default_bundler? + Gem.rubygems_version < Gem::Version.new("3.1.a") + end end diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb index 02a2c0f659..c76c3f505e 100644 --- a/spec/bundler/support/builders.rb +++ b/spec/bundler/support/builders.rb @@ -547,9 +547,11 @@ module Spec class GitBuilder < LibBuilder def _build(options) + default_branch = options[:default_branch] || "master" path = options[:path] || _default_path source = options[:source] || "git@#{path}" super(options.merge(:path => path, :source => source)) + @context.git("config --global init.defaultBranch #{default_branch}", path) @context.git("init", path) @context.git("add *", path) @context.git("config user.email lol@wut.com", path) -- cgit v1.2.3