diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-01 23:29:38 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-01 23:29:38 +0000 |
commit | be7b5929126cb3e696ef222339237faba9b8fe5a (patch) | |
tree | 51eae376f93c09bc82dde5a657a91df2c89062e4 /spec/bundler/install/gems | |
parent | ae49dbd392083f69026f2a0fff4a1d5f42d172a7 (diff) |
Update bundled bundler to 1.16.0.
* lib/bundler, spec/bundler: Merge bundler-1.16.0.
* common.mk: rspec examples of bundler-1.16.0 needs require option.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/bundler/install/gems')
-rw-r--r-- | spec/bundler/install/gems/compact_index_spec.rb | 148 | ||||
-rw-r--r-- | spec/bundler/install/gems/dependency_api_spec.rb | 127 | ||||
-rw-r--r-- | spec/bundler/install/gems/env_spec.rb | 1 | ||||
-rw-r--r-- | spec/bundler/install/gems/flex_spec.rb | 46 | ||||
-rw-r--r-- | spec/bundler/install/gems/mirror_spec.rb | 1 | ||||
-rw-r--r-- | spec/bundler/install/gems/native_extensions_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/install/gems/post_install_spec.rb | 1 | ||||
-rw-r--r-- | spec/bundler/install/gems/resolving_spec.rb | 15 | ||||
-rw-r--r-- | spec/bundler/install/gems/standalone_spec.rb | 45 | ||||
-rw-r--r-- | spec/bundler/install/gems/sudo_spec.rb | 15 | ||||
-rw-r--r-- | spec/bundler/install/gems/win32_spec.rb | 1 |
11 files changed, 309 insertions, 93 deletions
diff --git a/spec/bundler/install/gems/compact_index_spec.rb b/spec/bundler/install/gems/compact_index_spec.rb index 825185c82e..07700f5030 100644 --- a/spec/bundler/install/gems/compact_index_spec.rb +++ b/spec/bundler/install/gems/compact_index_spec.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require "spec_helper" RSpec.describe "compact index api" do let(:source_hostname) { "localgemserver.test" } @@ -61,7 +60,7 @@ RSpec.describe "compact index api" do # can't use `include_gems` here since the `require` will conflict on a # case-insensitive FS run! "Bundler.require; puts Gem.loaded_specs.values_at('rack', 'Rack').map(&:full_name)" - expect(out).to eq("rack-1.0\nRack-0.1") + expect(last_command.stdout).to eq("rack-1.0\nRack-0.1") end it "should handle multiple gem dependencies on the same gem" do @@ -81,7 +80,7 @@ RSpec.describe "compact index api" do G bundle! :install, :artifice => "compact_index" - bundle "install --deployment", :artifice => "compact_index" + bundle! :install, forgotten_command_line_options(:deployment => true, :path => "vendor/bundle").merge(:artifice => "compact_index") expect(out).to include("Fetching gem metadata from #{source_uri}") expect(the_bundle).to include_gems "rack 1.0.0" end @@ -130,9 +129,8 @@ RSpec.describe "compact index api" do G bundle "install", :artifice => "compact_index" - bundle "install --deployment", :artifice => "compact_index" + bundle! :install, forgotten_command_line_options(:deployment => true).merge(:artifice => "compact_index") - expect(exitstatus).to eq(0) if exitstatus expect(the_bundle).to include_gems("foo 1.0") end @@ -175,7 +173,7 @@ The checksum of /versions does not match the checksum provided by the server! So end it "falls back when the user's home directory does not exist or is not writable" do - ENV["HOME"] = nil + ENV["HOME"] = tmp("missing_home").to_s gemfile <<-G source "#{source_uri}" @@ -249,13 +247,29 @@ The checksum of /versions does not match the checksum provided by the server! So gem "rack" G - bundle "update --full-index", :artifice => "compact_index" + bundle! "update --full-index", :artifice => "compact_index", :all => bundle_update_requires_all? expect(out).to include("Fetching source index from #{source_uri}") expect(the_bundle).to include_gems "rack 1.0.0" end end - it "fetches again when more dependencies are found in subsequent sources" do + it "does not double check for gems that are only installed locally" do + system_gems %w[rack-1.0.0 thin-1.0 net_a-1.0] + bundle! "config --local path.system true" + ENV["BUNDLER_SPEC_ALL_REQUESTS"] = strip_whitespace(<<-EOS).strip + #{source_uri}/versions + #{source_uri}/info/rack + EOS + + install_gemfile! <<-G, :artifice => "compact_index", :verbose => true + source "#{source_uri}" + gem "rack" + G + + expect(last_command.stdboth).not_to include "Double checking" + end + + it "fetches again when more dependencies are found in subsequent sources", :bundler => "< 2" do build_repo2 do build_gem "back_deps" do |s| s.add_dependency "foo" @@ -270,7 +284,25 @@ The checksum of /versions does not match the checksum provided by the server! So G bundle! :install, :artifice => "compact_index_extra" - expect(the_bundle).to include_gems "back_deps 1.0" + expect(the_bundle).to include_gems "back_deps 1.0", "foo 1.0" + end + + it "fetches again when more dependencies are found in subsequent sources with source blocks" do + build_repo2 do + build_gem "back_deps" do |s| + s.add_dependency "foo" + end + FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")] + end + + install_gemfile! <<-G, :artifice => "compact_index_extra", :verbose => true + source "#{source_uri}" + source "#{source_uri}/extra" do + gem "back_deps" + end + G + + expect(the_bundle).to include_gems "back_deps 1.0", "foo 1.0" end it "fetches gem versions even when those gems are already installed" do @@ -296,7 +328,7 @@ The checksum of /versions does not match the checksum provided by the server! So expect(the_bundle).to include_gems "rack 1.2" end - it "considers all possible versions of dependencies from all api gem sources" do + it "considers all possible versions of dependencies from all api gem sources", :bundler => "< 2" do # In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that # exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0 # of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other @@ -320,6 +352,31 @@ The checksum of /versions does not match the checksum provided by the server! So expect(the_bundle).to include_gems "activesupport 1.2.3" end + it "considers all possible versions of dependencies from all api gem sources when using blocks", :bundler => "< 2" do + # In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that + # exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0 + # of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other + # repo and installs it. + build_repo4 do + build_gem "activesupport", "1.2.0" + build_gem "somegem", "1.0.0" do |s| + s.add_dependency "activesupport", "1.2.3" # This version exists only in repo1 + end + end + + gemfile <<-G + source "#{source_uri}" + source "#{source_uri}/extra" do + gem 'somegem', '1.0.0' + end + G + + bundle! :install, :artifice => "compact_index_extra_api" + + expect(the_bundle).to include_gems "somegem 1.0.0" + expect(the_bundle).to include_gems "activesupport 1.2.3" + end + it "prints API output properly with back deps" do build_repo2 do build_gem "back_deps" do |s| @@ -330,8 +387,9 @@ The checksum of /versions does not match the checksum provided by the server! So gemfile <<-G source "#{source_uri}" - source "#{source_uri}/extra" - gem "back_deps" + source "#{source_uri}/extra" do + gem "back_deps" + end G bundle! :install, :artifice => "compact_index_extra" @@ -356,14 +414,39 @@ The checksum of /versions does not match the checksum provided by the server! So gemfile <<-G source "#{source_uri}" - source "#{source_uri}/extra" - gem "back_deps" + source "#{source_uri}/extra" do + gem "back_deps" + end G bundle! :install, :artifice => "compact_index_extra_missing" expect(the_bundle).to include_gems "back_deps 1.0" end + it "does not fetch every spec if the index of gems is large when doing back deps & everything is the compact index" do + build_repo4 do + build_gem "back_deps" do |s| + s.add_dependency "foo" + end + build_gem "missing" + # need to hit the limit + 1.upto(Bundler::Source::Rubygems::API_REQUEST_LIMIT) do |i| + build_gem "gem#{i}" + end + + FileUtils.rm_rf Dir[gem_repo4("gems/foo-*.gem")] + end + + install_gemfile! <<-G, :artifice => "compact_index_extra_api_missing" + source "#{source_uri}" + source "#{source_uri}/extra" do + gem "back_deps" + end + G + + expect(the_bundle).to include_gem "back_deps 1.0" + end + it "uses the endpoint if all sources support it" do gemfile <<-G source "#{source_uri}" @@ -375,7 +458,7 @@ The checksum of /versions does not match the checksum provided by the server! So expect(the_bundle).to include_gems "foo 1.0" end - it "fetches again when more dependencies are found in subsequent sources using --deployment" do + it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 2" do build_repo2 do build_gem "back_deps" do |s| s.add_dependency "foo" @@ -395,6 +478,27 @@ The checksum of /versions does not match the checksum provided by the server! So expect(the_bundle).to include_gems "back_deps 1.0" end + it "fetches again when more dependencies are found in subsequent sources using --deployment with blocks" do + build_repo2 do + build_gem "back_deps" do |s| + s.add_dependency "foo" + end + FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")] + end + + gemfile <<-G + source "#{source_uri}" + source "#{source_uri}/extra" do + gem "back_deps" + end + G + + bundle! :install, :artifice => "compact_index_extra" + + bundle "install --deployment", :artifice => "compact_index_extra" + expect(the_bundle).to include_gems "back_deps 1.0" + end + it "does not refetch if the only unmet dependency is bundler" do gemfile <<-G source "#{source_uri}" @@ -418,7 +522,7 @@ The checksum of /versions does not match the checksum provided by the server! So expect(the_bundle).to include_gems "rails 2.3.2" end - it "installs the binstubs" do + it "installs the binstubs", :bundler => "< 2" do gemfile <<-G source "#{source_uri}" gem "rack" @@ -430,7 +534,7 @@ The checksum of /versions does not match the checksum provided by the server! So expect(out).to eq("1.0.0") end - it "installs the bins when using --path and uses autoclean" do + it "installs the bins when using --path and uses autoclean", :bundler => "< 2" do gemfile <<-G source "#{source_uri}" gem "rack" @@ -441,7 +545,7 @@ The checksum of /versions does not match the checksum provided by the server! So expect(vendored_gems("bin/rackup")).to exist end - it "installs the bins when using --path and uses bundle clean" do + it "installs the bins when using --path and uses bundle clean", :bundler => "< 2" do gemfile <<-G source "#{source_uri}" gem "rack" @@ -516,7 +620,7 @@ The checksum of /versions does not match the checksum provided by the server! So expect(out).not_to include("#{user}:#{password}") end - it "strips http basic auth creds when warning about ambiguous sources" do + it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 2" do gemfile <<-G source "#{basic_auth_source_uri}" source "file://#{gem_repo1}" @@ -613,7 +717,7 @@ The checksum of /versions does not match the checksum provided by the server! So end end - context "when ruby is compiled without openssl" do + context "when ruby is compiled without openssl", :ruby_repo do before do # Install a monkeypatch that reproduces the effects of openssl being # missing when the fetcher runs, as happens in real life. The reason @@ -640,7 +744,7 @@ The checksum of /versions does not match the checksum provided by the server! So context "when SSL certificate verification fails" do it "explains what happened" do # Install a monkeypatch that reproduces the effects of openssl raising - # a certificate validation error when Rubygems tries to connect. + # a certificate validation error when RubyGems tries to connect. gemfile <<-G class Net::HTTP def start @@ -741,7 +845,7 @@ The checksum of /versions does not match the checksum provided by the server! So and include("The checksum for the downloaded `rack-1.0.0.gem` does not match the checksum given by the server."). and include("This means the contents of the downloaded gem is different from what was uploaded to the server, and could be a potential security issue."). and include("To resolve this issue:"). - and include("1. delete the downloaded gem located at: `#{system_gem_path}/gems/rack-1.0.0/rack-1.0.0.gem`"). + and include("1. delete the downloaded gem located at: `#{default_bundle_path}/gems/rack-1.0.0/rack-1.0.0.gem`"). and include("2. run `bundle install`"). and include("If you wish to continue installing the downloaded gem, and are certain it does not pose a security issue despite the mismatching checksum, do the following:"). and include("1. run `bundle config disable_checksum_validation true` to turn off checksum verification"). diff --git a/spec/bundler/install/gems/dependency_api_spec.rb b/spec/bundler/install/gems/dependency_api_spec.rb index d2de0d358b..fe696f38c3 100644 --- a/spec/bundler/install/gems/dependency_api_spec.rb +++ b/spec/bundler/install/gems/dependency_api_spec.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require "spec_helper" RSpec.describe "gemcutter's dependency API" do let(:source_hostname) { "localgemserver.test" } @@ -61,7 +60,7 @@ RSpec.describe "gemcutter's dependency API" do G bundle :install, :artifice => "endpoint" - bundle "install --deployment", :artifice => "endpoint" + bundle! :install, forgotten_command_line_options(:deployment => true, :path => "vendor/bundle").merge(:artifice => "endpoint") expect(out).to include("Fetching gem metadata from #{source_uri}") expect(the_bundle).to include_gems "rack 1.0.0" end @@ -110,9 +109,8 @@ RSpec.describe "gemcutter's dependency API" do G bundle "install", :artifice => "endpoint" - bundle "install --deployment", :artifice => "endpoint" + bundle! :install, forgotten_command_line_options(:deployment => true).merge(:artifice => "endpoint") - expect(exitstatus).to eq(0) if exitstatus expect(the_bundle).to include_gems("foo 1.0") end @@ -239,13 +237,13 @@ RSpec.describe "gemcutter's dependency API" do gem "rack" G - bundle "update --full-index", :artifice => "endpoint" + bundle! "update --full-index", :artifice => "endpoint", :all => bundle_update_requires_all? expect(out).to include("Fetching source index from #{source_uri}") expect(the_bundle).to include_gems "rack 1.0.0" end end - it "fetches again when more dependencies are found in subsequent sources" do + it "fetches again when more dependencies are found in subsequent sources", :bundler => "< 2" do build_repo2 do build_gem "back_deps" do |s| s.add_dependency "foo" @@ -260,7 +258,26 @@ RSpec.describe "gemcutter's dependency API" do G bundle :install, :artifice => "endpoint_extra" - expect(the_bundle).to include_gems "back_deps 1.0" + expect(the_bundle).to include_gems "back_deps 1.0", "foo 1.0" + end + + it "fetches again when more dependencies are found in subsequent sources using blocks" do + build_repo2 do + build_gem "back_deps" do |s| + s.add_dependency "foo" + end + FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")] + end + + gemfile <<-G + source "#{source_uri}" + source "#{source_uri}/extra" do + gem "back_deps" + end + G + + bundle :install, :artifice => "endpoint_extra" + expect(the_bundle).to include_gems "back_deps 1.0", "foo 1.0" end it "fetches gem versions even when those gems are already installed" do @@ -285,7 +302,7 @@ RSpec.describe "gemcutter's dependency API" do expect(the_bundle).to include_gems "rack 1.2" end - it "considers all possible versions of dependencies from all api gem sources" do + it "considers all possible versions of dependencies from all api gem sources", :bundler => "< 2" do # In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that # exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0 # of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other @@ -303,6 +320,31 @@ RSpec.describe "gemcutter's dependency API" do gem 'somegem', '1.0.0' G + bundle! :install, :artifice => "endpoint_extra_api" + + expect(the_bundle).to include_gems "somegem 1.0.0" + expect(the_bundle).to include_gems "activesupport 1.2.3" + end + + it "considers all possible versions of dependencies from all api gem sources using blocks" do + # In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that + # exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0 + # of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other + # repo and installs it. + build_repo4 do + build_gem "activesupport", "1.2.0" + build_gem "somegem", "1.0.0" do |s| + s.add_dependency "activesupport", "1.2.3" # This version exists only in repo1 + end + end + + gemfile <<-G + source "#{source_uri}" + source "#{source_uri}/extra" do + gem 'somegem', '1.0.0' + end + G + bundle :install, :artifice => "endpoint_extra_api" expect(the_bundle).to include_gems "somegem 1.0.0" @@ -319,17 +361,18 @@ RSpec.describe "gemcutter's dependency API" do gemfile <<-G source "#{source_uri}" - source "#{source_uri}/extra" - gem "back_deps" + source "#{source_uri}/extra" do + gem "back_deps" + end G bundle :install, :artifice => "endpoint_extra" - expect(out).to include("Fetching gem metadata from http://localgemserver.test/..") + expect(out).to include("Fetching gem metadata from http://localgemserver.test/.") expect(out).to include("Fetching source index from http://localgemserver.test/extra") end - it "does not fetch every spec if the index of gems is large when doing back deps" do + it "does not fetch every spec if the index of gems is large when doing back deps", :bundler => "< 2" do build_repo2 do build_gem "back_deps" do |s| s.add_dependency "foo" @@ -353,6 +396,31 @@ RSpec.describe "gemcutter's dependency API" do expect(the_bundle).to include_gems "back_deps 1.0" end + it "does not fetch every spec if the index of gems is large when doing back deps using blocks" do + build_repo2 do + build_gem "back_deps" do |s| + s.add_dependency "foo" + end + build_gem "missing" + # need to hit the limit + 1.upto(Bundler::Source::Rubygems::API_REQUEST_LIMIT) do |i| + build_gem "gem#{i}" + end + + FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")] + end + + gemfile <<-G + source "#{source_uri}" + source "#{source_uri}/extra" do + gem "back_deps" + end + G + + bundle :install, :artifice => "endpoint_extra_missing" + 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}" @@ -364,7 +432,7 @@ RSpec.describe "gemcutter's dependency API" do expect(the_bundle).to include_gems "foo 1.0" end - it "fetches again when more dependencies are found in subsequent sources using --deployment" do + it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 2" do build_repo2 do build_gem "back_deps" do |s| s.add_dependency "foo" @@ -384,6 +452,27 @@ RSpec.describe "gemcutter's dependency API" do expect(the_bundle).to include_gems "back_deps 1.0" end + it "fetches again when more dependencies are found in subsequent sources using --deployment with blocks" do + build_repo2 do + build_gem "back_deps" do |s| + s.add_dependency "foo" + end + FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")] + end + + gemfile <<-G + source "#{source_uri}" + source "#{source_uri}/extra" do + gem "back_deps" + end + G + + bundle :install, :artifice => "endpoint_extra" + + bundle "install --deployment", :artifice => "endpoint_extra" + expect(the_bundle).to include_gems "back_deps 1.0" + end + it "does not refetch if the only unmet dependency is bundler" do gemfile <<-G source "#{source_uri}" @@ -407,7 +496,7 @@ RSpec.describe "gemcutter's dependency API" do expect(the_bundle).to include_gems "rails 2.3.2" end - it "installs the binstubs" do + it "installs the binstubs", :bundler => "< 2" do gemfile <<-G source "#{source_uri}" gem "rack" @@ -419,7 +508,7 @@ RSpec.describe "gemcutter's dependency API" do expect(out).to eq("1.0.0") end - it "installs the bins when using --path and uses autoclean" do + it "installs the bins when using --path and uses autoclean", :bundler => "< 2" do gemfile <<-G source "#{source_uri}" gem "rack" @@ -430,7 +519,7 @@ RSpec.describe "gemcutter's dependency API" do expect(vendored_gems("bin/rackup")).to exist end - it "installs the bins when using --path and uses bundle clean" do + it "installs the bins when using --path and uses bundle clean", :bundler => "< 2" do gemfile <<-G source "#{source_uri}" gem "rack" @@ -505,7 +594,7 @@ RSpec.describe "gemcutter's dependency API" do expect(out).not_to include("#{user}:#{password}") end - it "strips http basic auth creds when warning about ambiguous sources" do + it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 2" do gemfile <<-G source "#{basic_auth_source_uri}" source "file://#{gem_repo1}" @@ -602,7 +691,7 @@ RSpec.describe "gemcutter's dependency API" do end end - context "when ruby is compiled without openssl" do + context "when ruby is compiled without openssl", :ruby_repo do before do # Install a monkeypatch that reproduces the effects of openssl being # missing when the fetcher runs, as happens in real life. The reason @@ -629,7 +718,7 @@ RSpec.describe "gemcutter's dependency API" do context "when SSL certificate verification fails" do it "explains what happened" do # Install a monkeypatch that reproduces the effects of openssl raising - # a certificate validation error when Rubygems tries to connect. + # a certificate validation error when RubyGems tries to connect. gemfile <<-G class Net::HTTP def start diff --git a/spec/bundler/install/gems/env_spec.rb b/spec/bundler/install/gems/env_spec.rb index 9b1d8e5424..0dccbbfd24 100644 --- a/spec/bundler/install/gems/env_spec.rb +++ b/spec/bundler/install/gems/env_spec.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require "spec_helper" RSpec.describe "bundle install with ENV conditionals" do describe "when just setting an ENV key as a string" do diff --git a/spec/bundler/install/gems/flex_spec.rb b/spec/bundler/install/gems/flex_spec.rb index 2c2d3c16a1..f6af806154 100644 --- a/spec/bundler/install/gems/flex_spec.rb +++ b/spec/bundler/install/gems/flex_spec.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require "spec_helper" RSpec.describe "bundle flex_install" do it "installs the gems as expected" do @@ -194,8 +193,6 @@ RSpec.describe "bundle flex_install" do it "suggests bundle update when the Gemfile requires different versions than the lock" do nice_error = <<-E.strip.gsub(/^ {8}/, "") - Fetching source index from file:#{gem_repo2}/ - Resolving dependencies... Bundler could not find compatible versions for gem "rack": In snapshot (Gemfile.lock): rack (= 0.9.1) @@ -212,7 +209,7 @@ RSpec.describe "bundle flex_install" do E bundle :install, :retry => 0 - expect(out).to eq(nice_error) + expect(last_command.bundler_err).to end_with(nice_error) end end @@ -247,13 +244,13 @@ RSpec.describe "bundle flex_install" do end describe "when adding a new source" do - it "updates the lockfile" do + it "updates the lockfile", :bundler => "< 2" do build_repo2 - install_gemfile <<-G + install_gemfile! <<-G source "file://#{gem_repo1}" gem "rack" G - install_gemfile <<-G + install_gemfile! <<-G source "file://#{gem_repo1}" source "file://#{gem_repo2}" gem "rack" @@ -276,6 +273,41 @@ RSpec.describe "bundle flex_install" do #{Bundler::VERSION} L end + + it "updates the lockfile", :bundler => "2" do + build_repo2 + install_gemfile! <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + install_gemfile! <<-G + source "file://#{gem_repo1}" + source "file://#{gem_repo2}" do + end + gem "rack" + G + + lockfile_should_be <<-L + GEM + remote: file:#{gem_repo1}/ + specs: + rack (1.0.0) + + GEM + remote: file:#{gem_repo2}/ + specs: + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + #{Bundler::VERSION} + L + end end # This was written to test github issue #636 diff --git a/spec/bundler/install/gems/mirror_spec.rb b/spec/bundler/install/gems/mirror_spec.rb index 798156fb12..a8516a28c3 100644 --- a/spec/bundler/install/gems/mirror_spec.rb +++ b/spec/bundler/install/gems/mirror_spec.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require "spec_helper" RSpec.describe "bundle install with a mirror configured" do describe "when the mirror does not match the gem source" do diff --git a/spec/bundler/install/gems/native_extensions_spec.rb b/spec/bundler/install/gems/native_extensions_spec.rb index dcf67e976e..ea616f60d3 100644 --- a/spec/bundler/install/gems/native_extensions_spec.rb +++ b/spec/bundler/install/gems/native_extensions_spec.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require "spec_helper" RSpec.describe "installing a gem with native extensions", :ruby_repo do it "installs" do @@ -84,7 +83,6 @@ RSpec.describe "installing a gem with native extensions", :ruby_repo do G expect(out).not_to include("extconf.rb failed") - expect(out).to include("Using c_extension 1.0") run! "Bundler.require; puts CExtension.new.its_true" expect(out).to eq("true") diff --git a/spec/bundler/install/gems/post_install_spec.rb b/spec/bundler/install/gems/post_install_spec.rb index c3ea3e7c51..c6e348fb65 100644 --- a/spec/bundler/install/gems/post_install_spec.rb +++ b/spec/bundler/install/gems/post_install_spec.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require "spec_helper" RSpec.describe "bundle install" do context "with gem sources" do diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb index 7a341fd14f..23e3caaefc 100644 --- a/spec/bundler/install/gems/resolving_spec.rb +++ b/spec/bundler/install/gems/resolving_spec.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require "spec_helper" RSpec.describe "bundle install with install-time dependencies" do it "installs gems with implicit rake dependencies", :ruby_repo do @@ -92,8 +91,10 @@ RSpec.describe "bundle install with install-time dependencies" do bundle :install, :env => { "DEBUG_RESOLVER_TREE" => "1" } - expect(err).to include(" net_b") - expect(err).to include(" net_build_extensions (1.0)") + expect(err).to include(" net_b"). + and include("Starting resolution"). + and include("Finished resolution"). + and include("Attempting to activate") end end end @@ -141,9 +142,6 @@ RSpec.describe "bundle install with install-time dependencies" do expect(out).to_not include("Gem::InstallError: require_ruby requires Ruby version > 9000") nice_error = strip_whitespace(<<-E).strip - Fetching gem metadata from http://localgemserver.test/. - Fetching version metadata from http://localgemserver.test/ - Resolving dependencies... Bundler could not find compatible versions for gem "ruby\0": In Gemfile: ruby\0 (#{error_message_requirement}) @@ -151,9 +149,10 @@ RSpec.describe "bundle install with install-time dependencies" do require_ruby was resolved to 1.0, which depends on ruby\0 (> 9000) - Could not find gem 'ruby\0 (> 9000)', which is required by gem 'require_ruby', in any of the sources. + Could not find gem 'ruby\0 (> 9000)', which is required by gem 'require_ruby', in any of the relevant sources: + the local ruby installation E - expect(out).to eq(nice_error) + expect(last_command.bundler_err).to end_with(nice_error) end end diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb index 9a79a05b32..551f07848d 100644 --- a/spec/bundler/install/gems/standalone_spec.rb +++ b/spec/bundler/install/gems/standalone_spec.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require "spec_helper" RSpec.shared_examples "bundle install --standalone" do shared_examples "common functionality" do @@ -51,10 +50,11 @@ RSpec.shared_examples "bundle install --standalone" do describe "with simple gems" do before do - install_gemfile <<-G, :standalone => true + gemfile <<-G source "file://#{gem_repo1}" gem "rails" G + bundle! :install, forgotten_command_line_options(:path => "bundle").merge(:standalone => true) end let(:expected_gems) do @@ -69,7 +69,7 @@ RSpec.shared_examples "bundle install --standalone" do describe "with gems with native extension", :ruby_repo do before do - install_gemfile <<-G, :standalone => true + install_gemfile <<-G, forgotten_command_line_options(:path => "bundle").merge(:standalone => true) source "file://#{gem_repo1}" gem "very_simple_binary" G @@ -101,7 +101,7 @@ RSpec.shared_examples "bundle install --standalone" do end G end - install_gemfile <<-G, :standalone => true + install_gemfile <<-G, forgotten_command_line_options(:path => "bundle").merge(:standalone => true) gem "bar", :git => "#{lib_path("bar-1.0")}" G end @@ -116,11 +116,12 @@ RSpec.shared_examples "bundle install --standalone" do before do build_git "devise", "1.0" - install_gemfile <<-G, :standalone => true + gemfile <<-G source "file://#{gem_repo1}" gem "rails" gem "devise", :git => "#{lib_path("devise-1.0")}" G + bundle! :install, forgotten_command_line_options(:path => "bundle").merge(:standalone => true) end let(:expected_gems) do @@ -138,7 +139,7 @@ RSpec.shared_examples "bundle install --standalone" do before do build_git "devise", "1.0" - install_gemfile <<-G, :standalone => true + gemfile <<-G source "file://#{gem_repo1}" gem "rails" @@ -147,6 +148,7 @@ RSpec.shared_examples "bundle install --standalone" do gem "rack-test" end G + bundle! :install, forgotten_command_line_options(:path => "bundle").merge(:standalone => true) end let(:expected_gems) do @@ -159,7 +161,7 @@ RSpec.shared_examples "bundle install --standalone" do include_examples "common functionality" it "allows creating a standalone file with limited groups" do - bundle "install --standalone default" + bundle! "install", forgotten_command_line_options(:path => "bundle").merge(:standalone => "default") Dir.chdir(bundled_app) do load_error_ruby <<-RUBY, "spec", :no_lib => true @@ -172,12 +174,12 @@ RSpec.shared_examples "bundle install --standalone" do RUBY end - expect(out).to eq("2.3.2") - expect(err).to eq("ZOMG LOAD ERROR") + expect(last_command.stdout).to eq("2.3.2") + expect(last_command.stderr).to eq("ZOMG LOAD ERROR") end it "allows --without to limit the groups used in a standalone" do - bundle "install --standalone --without test" + bundle! :install, forgotten_command_line_options(:path => "bundle", :without => "test").merge(:standalone => true) Dir.chdir(bundled_app) do load_error_ruby <<-RUBY, "spec", :no_lib => true @@ -190,12 +192,12 @@ RSpec.shared_examples "bundle install --standalone" do RUBY end - expect(out).to eq("2.3.2") - expect(err).to eq("ZOMG LOAD ERROR") + expect(last_command.stdout).to eq("2.3.2") + expect(last_command.stderr).to eq("ZOMG LOAD ERROR") end it "allows --path to change the location of the standalone bundle" do - bundle "install --standalone --path path/to/bundle" + bundle! "install", forgotten_command_line_options(:path => "path/to/bundle").merge(:standalone => true) Dir.chdir(bundled_app) do ruby <<-RUBY, :no_lib => true @@ -207,12 +209,12 @@ RSpec.shared_examples "bundle install --standalone" do RUBY end - expect(out).to eq("2.3.2") + expect(last_command.stdout).to eq("2.3.2") end it "allows remembered --without to limit the groups used in a standalone" do - bundle "install --without test" - bundle "install --standalone" + bundle! :install, forgotten_command_line_options(:without => "test") + bundle! :install, forgotten_command_line_options(:path => "bundle").merge(:standalone => true) Dir.chdir(bundled_app) do load_error_ruby <<-RUBY, "spec", :no_lib => true @@ -225,8 +227,8 @@ RSpec.shared_examples "bundle install --standalone" do RUBY end - expect(out).to eq("2.3.2") - expect(err).to eq("ZOMG LOAD ERROR") + expect(last_command.stdout).to eq("2.3.2") + expect(last_command.stderr).to eq("ZOMG LOAD ERROR") end end @@ -239,7 +241,7 @@ RSpec.shared_examples "bundle install --standalone" do source "#{source_uri}" gem "rails" G - bundle "install --standalone", :artifice => "endpoint" + bundle! :install, forgotten_command_line_options(:path => "bundle").merge(:standalone => true, :artifice => "endpoint") end let(:expected_gems) do @@ -253,12 +255,13 @@ RSpec.shared_examples "bundle install --standalone" do end end - describe "with --binstubs" do + describe "with --binstubs", :bundler => "< 2" do before do - install_gemfile <<-G, :standalone => true, :binstubs => true + gemfile <<-G source "file://#{gem_repo1}" gem "rails" G + bundle! :install, forgotten_command_line_options(:path => "bundle").merge(:standalone => true, :binstubs => true) end let(:expected_gems) do diff --git a/spec/bundler/install/gems/sudo_spec.rb b/spec/bundler/install/gems/sudo_spec.rb index 13abffc14e..ae94eee9c6 100644 --- a/spec/bundler/install/gems/sudo_spec.rb +++ b/spec/bundler/install/gems/sudo_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require "spec_helper" RSpec.describe "when using sudo", :sudo => true do describe "and BUNDLE_PATH is writable" do context "but BUNDLE_PATH/build_info is not writable" do before do + bundle! "config path.system true" subdir = system_gem_path("cache") subdir.mkpath sudo "chmod u-w #{subdir}" @@ -25,6 +25,7 @@ RSpec.describe "when using sudo", :sudo => true do describe "and GEM_HOME is owned by root" do before :each do + bundle! "config path.system true" chown_system_gems_to_root end @@ -83,7 +84,7 @@ RSpec.describe "when using sudo", :sudo => true do expect(the_bundle).to include_gems "rack 1.0" end - it "installs extensions/ compiled by Rubygems 2.2", :rubygems => "2.2" do + it "installs extensions/ compiled by RubyGems 2.2", :rubygems => "2.2" do install_gemfile <<-G source "file://#{gem_repo1}" gem "very_simple_binary" @@ -128,6 +129,7 @@ RSpec.describe "when using sudo", :sudo => true do describe "and GEM_HOME is not writable" do it "installs" do + bundle! "config path.system true" gem_home = tmp("sudo_gem_home") sudo "mkdir -p #{gem_home}" sudo "chmod ugo-w #{gem_home}" @@ -162,16 +164,9 @@ RSpec.describe "when using sudo", :sudo => true do end end - context "when silence_root_warning is passed as an option" do - it "skips the warning" do - bundle :install, :sudo => true, :silence_root_warning => true - expect(out).to_not include(warning) - end - end - context "when silence_root_warning = false" do it "warns against that" do - bundle :install, :sudo => true, :silence_root_warning => false + bundle :install, :sudo => true, :env => { "BUNDLE_SILENCE_ROOT_WARNING" => "false" } expect(out).to include(warning) end end diff --git a/spec/bundler/install/gems/win32_spec.rb b/spec/bundler/install/gems/win32_spec.rb index cdad9a8821..ad758b94fa 100644 --- a/spec/bundler/install/gems/win32_spec.rb +++ b/spec/bundler/install/gems/win32_spec.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require "spec_helper" RSpec.describe "bundle install with win32-generated lockfile" do it "should read lockfile" do |