From 41a28637807bef9b15c404c93a778aaa6266ace7 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 2 Aug 2021 12:07:39 +0900 Subject: Merge RubyGems 3.2.25 and Bundler 2.2.25 --- spec/bundler/commands/binstubs_spec.rb | 17 ++++++--- spec/bundler/commands/check_spec.rb | 3 ++ spec/bundler/commands/clean_spec.rb | 15 ++++---- spec/bundler/commands/config_spec.rb | 16 ++++++++- spec/bundler/commands/exec_spec.rb | 64 +++++++++++++++++++++++----------- spec/bundler/commands/info_spec.rb | 4 +++ spec/bundler/commands/install_spec.rb | 56 +++++++++++++++++++++++++---- spec/bundler/commands/open_spec.rb | 1 + spec/bundler/commands/update_spec.rb | 20 ++++++++--- 9 files changed, 153 insertions(+), 43 deletions(-) (limited to 'spec/bundler/commands') diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb index 3b177b32ea..fb5da98bf3 100644 --- a/spec/bundler/commands/binstubs_spec.rb +++ b/spec/bundler/commands/binstubs_spec.rb @@ -140,8 +140,15 @@ RSpec.describe "bundle binstubs " do it "runs the correct version of bundler" do sys_exec "bin/bundle install", :env => { "BUNDLER_VERSION" => "999.999.999" }, :raise_on_error => false expect(exitstatus).to eq(42) - expect(err).to include("Activating bundler (~> 999.999) failed:"). - and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`") + expect(err).to include("Activating bundler (999.999.999) failed:"). + and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`") + end + + it "runs the correct version of bundler even if a higher version is installed" do + system_gems "bundler-999.999.998", "bundler-999.999.999" + + sys_exec "bin/bundle install", :env => { "BUNDLER_VERSION" => "999.999.998", "DEBUG" => "1" }, :raise_on_error => false + expect(out).to include %(Using bundler 999.999.998\n) end end @@ -215,8 +222,8 @@ RSpec.describe "bundle binstubs " do it "calls through to the explicit bundler version" do sys_exec "bin/bundle update --bundler=999.999.999", :raise_on_error => false expect(exitstatus).to eq(42) - expect(err).to include("Activating bundler (~> 999.999) failed:"). - and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`") + expect(err).to include("Activating bundler (999.999.999) failed:"). + and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`") end end @@ -254,6 +261,7 @@ RSpec.describe "bundle binstubs " do s.executables = %w[foo] end install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "foo", :git => "#{lib_path("foo")}" G @@ -269,6 +277,7 @@ RSpec.describe "bundle binstubs " do s.executables = %w[foo] end install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "foo", :path => "#{lib_path("foo")}" G diff --git a/spec/bundler/commands/check_spec.rb b/spec/bundler/commands/check_spec.rb index 88950cef85..c48220f8df 100644 --- a/spec/bundler/commands/check_spec.rb +++ b/spec/bundler/commands/check_spec.rb @@ -319,6 +319,7 @@ RSpec.describe "bundle check" do describe "when using only scoped rubygems sources" do before do gemfile <<~G + source "#{file_uri_for(gem_repo2)}" source "#{file_uri_for(gem_repo1)}" do gem "rack" end @@ -343,6 +344,7 @@ RSpec.describe "bundle check" do end gemfile <<~G + source "#{file_uri_for(gem_repo1)}" source "#{file_uri_for(gem_repo4)}" do gem "depends_on_rack" end @@ -355,6 +357,7 @@ RSpec.describe "bundle check" do expect(out).to include("The Gemfile's dependencies are satisfied") expect(lockfile).to eq <<~L GEM + remote: #{file_uri_for(gem_repo1)}/ specs: GEM diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb index 7c43aaabc4..429fb17d82 100644 --- a/spec/bundler/commands/clean_spec.rb +++ b/spec/bundler/commands/clean_spec.rb @@ -261,6 +261,7 @@ RSpec.describe "bundle clean" do revision = revision_for(lib_path("rails")) gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "activesupport", :git => "#{lib_path("rails")}", :ref => '#{revision}' G @@ -625,21 +626,19 @@ RSpec.describe "bundle clean" do end it "when using --force, it doesn't remove default gem binaries" do - skip "does not work on ruby 3.0 because it changes the path to look for default gems, tsort is a default gem there, and we can't install it either like we do with fiddle because it doesn't yet exist" unless RUBY_VERSION < "3.0.0" + skip "does not work on old rubies because the realworld gems that need to be installed don't support them" if RUBY_VERSION < "2.7.0" skip "does not work on rubygems versions where `--install_dir` doesn't respect --default" unless Gem::Installer.for_spec(loaded_gemspec, :install_dir => "/foo").default_spec_file == "/foo/specifications/default/bundler-#{Bundler::VERSION}.gemspec" # Since rubygems 3.2.0.rc.2 default_irb_version = ruby "gem 'irb', '< 999999'; require 'irb'; puts IRB::VERSION", :raise_on_error => false skip "irb isn't a default gem" if default_irb_version.empty? - build_repo2 do - # simulate executable for default gem - build_gem "irb", default_irb_version, :to_system => true, :default => true do |s| - s.executables = "irb" - end + # simulate executable for default gem + build_gem "irb", default_irb_version, :to_system => true, :default => true do |s| + s.executables = "irb" end - realworld_system_gems "fiddle --version 1.0.0" + realworld_system_gems "fiddle --version 1.0.6", "tsort --version 0.1.0", "pathname --version 0.1.0", "set --version 1.0.1" install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" @@ -869,6 +868,7 @@ RSpec.describe "bundle clean" do expect(very_simple_binary_extensions_dir).to exist gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}" G @@ -878,6 +878,7 @@ RSpec.describe "bundle clean" do expect(very_simple_binary_extensions_dir).to exist gemfile <<-G + source "#{file_uri_for(gem_repo1)}" G bundle "install" diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index 2f4488a552..4e13a7903e 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -76,6 +76,20 @@ RSpec.describe ".bundle/config" do end end + describe "config location" do + let(:bundle_user_config) { File.join(Dir.home, ".config/bundler") } + + before do + Dir.mkdir File.dirname(bundle_user_config) + end + + it "can be configured through BUNDLE_USER_CONFIG" do + bundle "config set path vendor", :env => { "BUNDLE_USER_CONFIG" => bundle_user_config } + bundle "config get path", :env => { "BUNDLE_USER_CONFIG" => bundle_user_config } + expect(out).to include("Set for the current user (#{bundle_user_config}): \"vendor\"") + end + end + describe "global" do before(:each) do install_gemfile <<-G @@ -321,7 +335,7 @@ E end describe "quoting" do - before(:each) { gemfile "# no gems" } + before(:each) { gemfile "source \"#{file_uri_for(gem_repo1)}\"" } let(:long_string) do "--with-xml2-include=/usr/pkg/include/libxml2 --with-xml2-lib=/usr/pkg/lib " \ "--with-xslt-dir=/usr/pkg" diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index 39430d52a4..68c4726608 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -8,6 +8,7 @@ RSpec.describe "bundle exec" do it "works with --gemfile flag" do create_file "CustomGemfile", <<-G + source "#{file_uri_for(gem_repo1)}" gem "rack", "1.0.0" G @@ -17,6 +18,7 @@ RSpec.describe "bundle exec" do it "activates the correct gem" do gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "rack", "0.9.1" G @@ -26,6 +28,7 @@ RSpec.describe "bundle exec" do it "works and prints no warnings when HOME is not writable" do gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "rack", "0.9.1" G @@ -36,6 +39,7 @@ RSpec.describe "bundle exec" do it "works when the bins are in ~/.bundle" do install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "rack" G @@ -45,6 +49,7 @@ RSpec.describe "bundle exec" do it "works when running from a random directory" do install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "rack" G @@ -54,37 +59,39 @@ RSpec.describe "bundle exec" do end it "works when exec'ing something else" do - install_gemfile 'gem "rack"' + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"; gem \"rack\"" bundle "exec echo exec" expect(out).to eq("exec") end it "works when exec'ing to ruby" do - install_gemfile 'gem "rack"' + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"; gem \"rack\"" bundle "exec ruby -e 'puts %{hi}'" expect(out).to eq("hi") end it "works when exec'ing to rubygems" do - install_gemfile 'gem "rack"' + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"; gem \"rack\"" bundle "exec #{gem_cmd} --version" expect(out).to eq(Gem::VERSION) end it "works when exec'ing to rubygems through sh -c" do - install_gemfile 'gem "rack"' + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"; gem \"rack\"" bundle "exec sh -c '#{gem_cmd} --version'" expect(out).to eq(Gem::VERSION) end it "works when exec'ing back to bundler with a lockfile that doesn't include the current platform" do install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "rack", "0.9.1" G # simulate lockfile generated with old version not including specific platform lockfile <<-L GEM + remote: #{file_uri_for(gem_repo1)}/ specs: rack (0.9.1) @@ -110,20 +117,20 @@ RSpec.describe "bundle exec" do Process.setproctitle("1-2-3-4-5-6-7") puts `ps -ocommand= -p#{$$}` RUBY - create_file "Gemfile" + create_file "Gemfile", "source \"#{file_uri_for(gem_repo1)}\"" create_file "a.rb", script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility bundle "exec ruby a.rb" expect(out).to eq("1-2-3-4-5-6-7") end it "accepts --verbose" do - install_gemfile 'gem "rack"' + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"; gem \"rack\"" bundle "exec --verbose echo foobar" expect(out).to eq("foobar") end it "passes --verbose to command if it is given after the command" do - install_gemfile 'gem "rack"' + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"; gem \"rack\"" bundle "exec echo --verbose" expect(out).to eq("--verbose") end @@ -147,7 +154,7 @@ RSpec.describe "bundle exec" do end G - install_gemfile "" + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"" sys_exec "#{Gem.ruby} #{command.path}" expect(out).to be_empty @@ -155,7 +162,7 @@ RSpec.describe "bundle exec" do end it "accepts --keep-file-descriptors" do - install_gemfile "" + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"" bundle "exec --keep-file-descriptors echo foobar" expect(err).to be_empty @@ -164,7 +171,7 @@ RSpec.describe "bundle exec" do it "can run a command named --verbose" do skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform? - install_gemfile 'gem "rack"' + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"; gem \"rack\"" File.open(bundled_app("--verbose"), "w") do |f| f.puts "#!/bin/sh" f.puts "echo foobar" @@ -210,7 +217,7 @@ RSpec.describe "bundle exec" do before do skip "irb isn't a default gem" if default_irb_version.empty? - install_gemfile "" + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"" end it "uses version provided by ruby" do @@ -325,6 +332,7 @@ RSpec.describe "bundle exec" do skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform? install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "rack" G @@ -343,6 +351,7 @@ RSpec.describe "bundle exec" do skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform? install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "rack" G @@ -359,6 +368,7 @@ RSpec.describe "bundle exec" do it "errors nicely when the argument doesn't exist" do install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "rack" G @@ -370,6 +380,7 @@ RSpec.describe "bundle exec" do it "errors nicely when the argument is not executable" do install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "rack" G @@ -381,6 +392,7 @@ RSpec.describe "bundle exec" do it "errors nicely when no arguments are passed" do install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "rack" G @@ -412,6 +424,7 @@ RSpec.describe "bundle exec" do skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform? install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "rack" G @@ -496,6 +509,7 @@ RSpec.describe "bundle exec" do describe "run from a random directory" do before(:each) do install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "rack" G end @@ -519,6 +533,7 @@ RSpec.describe "bundle exec" do end install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "fizz", :path => "#{File.expand_path(home("fizz"))}" G end @@ -543,6 +558,7 @@ RSpec.describe "bundle exec" do end install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "fizz_git", :git => "#{lib_path("fizz_git-1.0")}" G end @@ -566,6 +582,7 @@ RSpec.describe "bundle exec" do end install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "fizz_no_gemspec", "1.0", :git => "#{lib_path("fizz_no_gemspec-1.0")}" G end @@ -612,6 +629,7 @@ RSpec.describe "bundle exec" do end gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "foo", :path => "#{lib_path("foo-1.0")}" G @@ -627,6 +645,8 @@ RSpec.describe "bundle exec" do skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform? gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + module Monkey def bin_path(a,b,c) raise Gem::GemNotFoundException.new('Fail') @@ -660,6 +680,7 @@ RSpec.describe "bundle exec" do bundled_app(path).chmod(0o755) install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "rack" G end @@ -806,6 +827,7 @@ RSpec.describe "bundle exec" do context "when Bundler.setup fails", :bundler => "< 3" do before do gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem 'rack', '2' G ENV["BUNDLER_FORCE_TTY"] = "true" @@ -814,9 +836,9 @@ RSpec.describe "bundle exec" do let(:exit_code) { Bundler::GemNotFound.new.status_code } let(:expected) { "" } let(:expected_err) { <<-EOS.strip } -\e[31mCould not find gem 'rack (= 2)' in locally installed gems. -The source contains the following versions of 'rack': 0.9.1, 1.0.0\e[0m -\e[33mRun `bundle install` to install missing gems.\e[0m +Could not find gem 'rack (= 2)' in rubygems repository #{file_uri_for(gem_repo1)}/ or installed locally. +The source contains the following versions of 'rack': 0.9.1, 1.0.0 +Run `bundle install` to install missing gems. EOS it "runs" do @@ -832,6 +854,7 @@ The source contains the following versions of 'rack': 0.9.1, 1.0.0\e[0m context "when Bundler.setup fails", :bundler => "3" do before do gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem 'rack', '2' G ENV["BUNDLER_FORCE_TTY"] = "true" @@ -840,9 +863,9 @@ The source contains the following versions of 'rack': 0.9.1, 1.0.0\e[0m let(:exit_code) { Bundler::GemNotFound.new.status_code } let(:expected) { "" } let(:expected_err) { <<-EOS.strip } -\e[31mCould not find gem 'rack (= 2)' in locally installed gems. -The source contains the following versions of 'rack': 1.0.0\e[0m -\e[33mRun `bundle install` to install missing gems.\e[0m +Could not find gem 'rack (= 2)' in rubygems repository #{file_uri_for(gem_repo1)}/ or installed locally. +The source contains the following versions of 'rack': 1.0.0 +Run `bundle install` to install missing gems. EOS it "runs" do @@ -1020,7 +1043,7 @@ __FILE__: #{path.to_s.inspect} before do skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform? - install_gemfile "" + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"" end it "does not undo the monkeypatches" do @@ -1079,7 +1102,7 @@ __FILE__: #{path.to_s.inspect} RUBY # A Gemfile needs to be in the root to trick bundler's root resolution - create_file(bundled_app("Gemfile")) + create_file(bundled_app("Gemfile"), "source \"#{file_uri_for(gem_repo1)}\"") bundle "install" end @@ -1110,7 +1133,7 @@ __FILE__: #{path.to_s.inspect} skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform? skip "openssl isn't a default gem" if expected.empty? - install_gemfile "" # must happen before installing the broken system gem + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"" # must happen before installing the broken system gem build_repo4 do build_gem "openssl", openssl_version do |s| @@ -1151,6 +1174,7 @@ __FILE__: #{path.to_s.inspect} build_git "simple_git_binary", &:add_c_extension bundle "config set --local path .bundle" install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "simple_git_binary", :git => '#{lib_path("simple_git_binary-1.0")}' G end diff --git a/spec/bundler/commands/info_spec.rb b/spec/bundler/commands/info_spec.rb index daed4587d5..906349cacf 100644 --- a/spec/bundler/commands/info_spec.rb +++ b/spec/bundler/commands/info_spec.rb @@ -111,6 +111,7 @@ RSpec.describe "bundle info" do it "prints out git info" do install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "foo", :git => "#{lib_path("foo-1.0")}" G expect(the_bundle).to include_gems "foo 1.0" @@ -126,6 +127,7 @@ RSpec.describe "bundle info" do @revision = revision_for(lib_path("foo-1.0"))[0...6] install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "omg" G expect(the_bundle).to include_gems "foo 1.0.omg" @@ -137,6 +139,7 @@ RSpec.describe "bundle info" do it "doesn't print the branch when tied to a ref" do sha = revision_for(lib_path("foo-1.0")) install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "foo", :git => "#{lib_path("foo-1.0")}", :ref => "#{sha}" G @@ -147,6 +150,7 @@ RSpec.describe "bundle info" do it "handles when a version is a '-' prerelease" do @git = build_git("foo", "1.0.0-beta.1", :path => lib_path("foo")) install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "foo", "1.0.0-beta.1", :git => "#{lib_path("foo")}" G expect(the_bundle).to include_gems "foo 1.0.0.pre.beta.1" diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index 00a277a826..412000341f 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -334,11 +334,15 @@ RSpec.describe "bundle install with gem sources" do gem "rack" G - expect(err).to include("Your Gemfile has no gem server sources") + expect(err).to include("This Gemfile does not include an explicit global source. " \ + "Not using an explicit global source may result in a different lockfile being generated depending on " \ + "the gems you have installed locally before bundler is run." \ + "Instead, define a global source in your Gemfile like this: source \"https://rubygems.org\".") end it "creates a Gemfile.lock on a blank Gemfile" do install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" G expect(File.exist?(bundled_app_lock)).to eq(true) @@ -448,7 +452,7 @@ RSpec.describe "bundle install with gem sources" do expect(last_command.stdboth).not_to match(/Error Report/i) expect(err).to include("An error occurred while installing ajp-rails (0.0.0), and Bundler cannot continue."). - and include("Make sure that `gem install ajp-rails -v '0.0.0' --source '#{file_uri_for(gem_repo2)}/'` succeeds before bundling.") + and include("Bundler::APIResponseInvalidDependenciesError") end it "doesn't blow up when the local .bundle/config is empty" do @@ -482,6 +486,7 @@ RSpec.describe "bundle install with gem sources" do install_gemfile <<-G, :raise_on_error => false ::RUBY_VERSION = '2.0.1' ruby '~> 2.2' + source "#{file_uri_for(gem_repo1)}" G expect(err).to include("Your Ruby version is 2.0.1, but your Gemfile specified ~> 2.2") end @@ -493,12 +498,14 @@ RSpec.describe "bundle install with gem sources" do ::RUBY_VERSION = '2.1.3' ::RUBY_PATCHLEVEL = 100 ruby '~> 2.1.0' + source "#{file_uri_for(gem_repo1)}" G end it "writes current Ruby version to Gemfile.lock" do lockfile_should_be <<-L GEM + remote: #{file_uri_for(gem_repo1)}/ specs: PLATFORMS @@ -519,10 +526,12 @@ RSpec.describe "bundle install with gem sources" do ::RUBY_VERSION = '2.2.3' ::RUBY_PATCHLEVEL = 100 ruby '~> 2.2.0' + source "#{file_uri_for(gem_repo1)}" G lockfile_should_be <<-L GEM + remote: #{file_uri_for(gem_repo1)}/ specs: PLATFORMS @@ -540,6 +549,7 @@ RSpec.describe "bundle install with gem sources" do it "does not crash when unlocking" do gemfile <<-G + source "#{file_uri_for(gem_repo1)}" ruby '>= 2.1.0' G @@ -558,6 +568,7 @@ RSpec.describe "bundle install with gem sources" do build_lib "foo" gemfile = <<-G + source "#{file_uri_for(gem_repo1)}" gem 'foo', :path => "#{lib_path("foo-1.0")}" G File.open("#{root_dir}/Gemfile", "w") do |file| @@ -574,6 +585,7 @@ RSpec.describe "bundle install with gem sources" do build_lib "foo", :path => root_dir gemfile = <<-G + source "#{file_uri_for(gem_repo1)}" gemspec G File.open("#{root_dir}/Gemfile", "w") do |file| @@ -585,16 +597,48 @@ RSpec.describe "bundle install with gem sources" do end describe "when requesting a quiet install via --quiet" do - it "should be quiet" do + it "should be quiet if there are no warnings" do bundle "config set force_ruby_platform true" gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem 'rack' G - bundle :install, :quiet => true, :raise_on_error => false - expect(err).to include("Could not find gem 'rack'") - expect(err).to_not include("Your Gemfile has no gem server sources") + bundle :install, :quiet => true + expect(out).to be_empty + expect(err).to be_empty + end + + it "should still display warnings and errors" do + bundle "config set force_ruby_platform true" + + create_file("install_with_warning.rb", <<~RUBY) + require "#{lib_dir}/bundler" + require "#{lib_dir}/bundler/cli" + require "#{lib_dir}/bundler/cli/install" + + module RunWithWarning + def run + super + rescue + Bundler.ui.warn "BOOOOO" + raise + end + end + + Bundler::CLI::Install.prepend(RunWithWarning) + RUBY + + gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + gem 'non-existing-gem' + G + + bundle :install, :quiet => true, :raise_on_error => false, :env => { "RUBYOPT" => "-r#{bundled_app("install_with_warning.rb")}" } + expect(out).to be_empty + expect(err).to include("Could not find gem 'non-existing-gem'") + expect(err).to include("BOOOOO") end end diff --git a/spec/bundler/commands/open_spec.rb b/spec/bundler/commands/open_spec.rb index d18e620783..53dc35c2c7 100644 --- a/spec/bundler/commands/open_spec.rb +++ b/spec/bundler/commands/open_spec.rb @@ -105,6 +105,7 @@ RSpec.describe "bundle open" do skip "No default gems available on this test run" if default_gems.empty? install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "json" G end diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index f9548238e9..14fe3e245b 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -66,7 +66,7 @@ RSpec.describe "bundle update" do end it "doesn't delete the Gemfile.lock file if something goes wrong" do - install_gemfile "" + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"" gemfile <<-G source "#{file_uri_for(gem_repo2)}" @@ -96,19 +96,19 @@ RSpec.describe "bundle update" do before { bundle "config set update_requires_all_flag true" } it "errors when passed nothing" do - install_gemfile "" + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"" bundle :update, :raise_on_error => false expect(err).to eq("To update everything, pass the `--all` flag.") end it "errors when passed --all and another option" do - install_gemfile "" + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"" bundle "update --all foo", :raise_on_error => false expect(err).to eq("Cannot specify --all along with specific options.") end it "updates everything when passed --all" do - install_gemfile "" + install_gemfile "source \"#{file_uri_for(gem_repo1)}\"" bundle "update --all" expect(out).to include("Bundle updated!") end @@ -753,6 +753,7 @@ RSpec.describe "bundle update in more complicated situations" do build_git "foo" install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem "foo", :git => '#{lib_path("foo-1.0")}' G @@ -769,6 +770,7 @@ RSpec.describe "bundle update in more complicated situations" do build_git "rack" install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" gem "rack", :git => '#{lib_path("rack-1.0")}' G @@ -922,6 +924,7 @@ RSpec.describe "bundle update --ruby" do ::RUBY_VERSION = '2.1.3' ::RUBY_PATCHLEVEL = 100 ruby '~> 2.1.0' + source "#{file_uri_for(gem_repo1)}" G end @@ -930,6 +933,7 @@ RSpec.describe "bundle update --ruby" do gemfile <<-G ::RUBY_VERSION = '2.1.4' ::RUBY_PATCHLEVEL = 222 + source "#{file_uri_for(gem_repo1)}" G end it "removes the Ruby from the Gemfile.lock" do @@ -937,6 +941,7 @@ RSpec.describe "bundle update --ruby" do lockfile_should_be <<-L GEM + remote: #{file_uri_for(gem_repo1)}/ specs: PLATFORMS @@ -956,6 +961,7 @@ RSpec.describe "bundle update --ruby" do ::RUBY_VERSION = '2.1.4' ::RUBY_PATCHLEVEL = 222 ruby '~> 2.1.0' + source "#{file_uri_for(gem_repo1)}" G end it "updates the Gemfile.lock with the latest version" do @@ -963,6 +969,7 @@ RSpec.describe "bundle update --ruby" do lockfile_should_be <<-L GEM + remote: #{file_uri_for(gem_repo1)}/ specs: PLATFORMS @@ -985,6 +992,7 @@ RSpec.describe "bundle update --ruby" do ::RUBY_VERSION = '2.2.2' ::RUBY_PATCHLEVEL = 505 ruby '~> 2.1.0' + source "#{file_uri_for(gem_repo1)}" G end it "shows a helpful error message" do @@ -1000,6 +1008,7 @@ RSpec.describe "bundle update --ruby" do ::RUBY_VERSION = '1.8.3' ::RUBY_PATCHLEVEL = 55 ruby '~> 1.8.0' + source "#{file_uri_for(gem_repo1)}" G end it "updates the Gemfile.lock with the latest version" do @@ -1007,6 +1016,7 @@ RSpec.describe "bundle update --ruby" do lockfile_should_be <<-L GEM + remote: #{file_uri_for(gem_repo1)}/ specs: PLATFORMS @@ -1248,7 +1258,7 @@ RSpec.describe "bundle update conservative" do context "error handling" do before do - gemfile "" + gemfile "source \"#{file_uri_for(gem_repo1)}\"" end it "raises if too many flags are provided" do -- cgit v1.2.3