summaryrefslogtreecommitdiff
path: root/spec/bundler/install/gems
diff options
context:
space:
mode:
Diffstat (limited to 'spec/bundler/install/gems')
-rw-r--r--spec/bundler/install/gems/compact_index_spec.rb909
-rw-r--r--spec/bundler/install/gems/dependency_api_spec.rb760
-rw-r--r--spec/bundler/install/gems/env_spec.rb107
-rw-r--r--spec/bundler/install/gems/flex_spec.rb351
-rw-r--r--spec/bundler/install/gems/mirror_spec.rb39
-rw-r--r--spec/bundler/install/gems/native_extensions_spec.rb90
-rw-r--r--spec/bundler/install/gems/post_install_spec.rb150
-rw-r--r--spec/bundler/install/gems/resolving_spec.rb194
-rw-r--r--spec/bundler/install/gems/standalone_spec.rb321
-rw-r--r--spec/bundler/install/gems/sudo_spec.rb174
-rw-r--r--spec/bundler/install/gems/win32_spec.rb26
11 files changed, 0 insertions, 3121 deletions
diff --git a/spec/bundler/install/gems/compact_index_spec.rb b/spec/bundler/install/gems/compact_index_spec.rb
deleted file mode 100644
index 07700f5030..0000000000
--- a/spec/bundler/install/gems/compact_index_spec.rb
+++ /dev/null
@@ -1,909 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "compact index api" do
- let(:source_hostname) { "localgemserver.test" }
- let(:source_uri) { "http://#{source_hostname}" }
-
- it "should use the API" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "should URI encode gem names" do
- gemfile <<-G
- source "#{source_uri}"
- gem " sinatra"
- G
-
- bundle :install, :artifice => "compact_index"
- expect(out).to include("' sinatra' is not a valid gem name because it contains whitespace.")
- end
-
- it "should handle nested dependencies" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rails"
- G
-
- bundle! :install, :artifice => "compact_index"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems(
- "rails 2.3.2",
- "actionpack 2.3.2",
- "activerecord 2.3.2",
- "actionmailer 2.3.2",
- "activeresource 2.3.2",
- "activesupport 2.3.2"
- )
- end
-
- it "should handle case sensitivity conflicts" do
- build_repo4 do
- build_gem "rack", "1.0" do |s|
- s.add_runtime_dependency("Rack", "0.1")
- end
- build_gem "Rack", "0.1"
- end
-
- install_gemfile! <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4 }
- source "#{source_uri}"
- gem "rack", "1.0"
- gem "Rack", "0.1"
- G
-
- # 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(last_command.stdout).to eq("rack-1.0\nRack-0.1")
- end
-
- it "should handle multiple gem dependencies on the same gem" do
- gemfile <<-G
- source "#{source_uri}"
- gem "net-sftp"
- G
-
- bundle! :install, :artifice => "compact_index"
- expect(the_bundle).to include_gems "net-sftp 1.1.1"
- end
-
- it "should use the endpoint when using --deployment" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
- bundle! :install, :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
-
- it "handles git dependencies that are in rubygems" do
- build_git "foo" do |s|
- s.executables = "foobar"
- s.add_dependency "rails", "2.3.2"
- end
-
- gemfile <<-G
- source "#{source_uri}"
- git "file:///#{lib_path("foo-1.0")}" do
- gem 'foo'
- end
- G
-
- bundle! :install, :artifice => "compact_index"
-
- expect(the_bundle).to include_gems("rails 2.3.2")
- end
-
- it "handles git dependencies that are in rubygems using --deployment" do
- build_git "foo" do |s|
- s.executables = "foobar"
- s.add_dependency "rails", "2.3.2"
- end
-
- gemfile <<-G
- source "#{source_uri}"
- gem 'foo', :git => "file:///#{lib_path("foo-1.0")}"
- G
-
- bundle! :install, :artifice => "compact_index"
-
- bundle "install --deployment", :artifice => "compact_index"
-
- expect(the_bundle).to include_gems("rails 2.3.2")
- end
-
- it "doesn't fail if you only have a git gem with no deps when using --deployment" do
- build_git "foo"
- gemfile <<-G
- source "#{source_uri}"
- gem 'foo', :git => "file:///#{lib_path("foo-1.0")}"
- G
-
- bundle "install", :artifice => "compact_index"
- bundle! :install, forgotten_command_line_options(:deployment => true).merge(:artifice => "compact_index")
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
-
- it "falls back when the API errors out" do
- simulate_platform mswin
-
- gemfile <<-G
- source "#{source_uri}"
- gem "rcov"
- G
-
- bundle! :install, :artifice => "windows"
- expect(out).to include("Fetching source index from #{source_uri}")
- expect(the_bundle).to include_gems "rcov 1.0.0"
- end
-
- it "falls back when the API URL returns 403 Forbidden" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle! :install, :verbose => true, :artifice => "compact_index_forbidden"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "falls back when the versions endpoint has a checksum mismatch" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle! :install, :verbose => true, :artifice => "compact_index_checksum_mismatch"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(out).to include <<-'WARN'
-The checksum of /versions does not match the checksum provided by the server! Something is wrong (local checksum is "\"d41d8cd98f00b204e9800998ecf8427e\"", was expecting "\"123\"").
- WARN
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "falls back when the user's home directory does not exist or is not writable" do
- ENV["HOME"] = tmp("missing_home").to_s
-
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "handles host redirects" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index_host_redirect"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "handles host redirects without Net::HTTP::Persistent" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- FileUtils.mkdir_p lib_path
- File.open(lib_path("disable_net_http_persistent.rb"), "w") do |h|
- h.write <<-H
- module Kernel
- alias require_without_disabled_net_http require
- def require(*args)
- raise LoadError, 'simulated' if args.first == 'openssl' && !caller.grep(/vendored_persistent/).empty?
- require_without_disabled_net_http(*args)
- end
- end
- H
- end
-
- bundle! :install, :artifice => "compact_index_host_redirect", :requires => [lib_path("disable_net_http_persistent.rb")]
- expect(out).to_not match(/Too many redirects/)
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "times out when Bundler::Fetcher redirects too much" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "compact_index_redirects"
- expect(out).to match(/Too many redirects/)
- end
-
- context "when --full-index is specified" do
- it "should use the modern index for install" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --full-index", :artifice => "compact_index"
- expect(out).to include("Fetching source index from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "should use the modern index for update" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- 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 "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"
- end
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra"
- gem "back_deps"
- G
-
- bundle! :install, :artifice => "compact_index_extra"
- 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
- gemfile <<-G
- source "#{source_uri}"
- gem "rack", "1.0.0"
- G
- bundle! :install, :artifice => "compact_index_extra_api"
- expect(the_bundle).to include_gems "rack 1.0.0"
-
- build_repo4 do
- build_gem "rack", "1.2" do |s|
- s.executables = "rackup"
- end
- end
-
- gemfile <<-G
- source "#{source_uri}" do; end
- source "#{source_uri}/extra"
- gem "rack", "1.2"
- G
- bundle! :install, :artifice => "compact_index_extra_api"
- expect(the_bundle).to include_gems "rack 1.2"
- end
-
- 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
- # 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"
- gem 'somegem', '1.0.0'
- 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 "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|
- 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"
-
- 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
- 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 => "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}"
-
- gem 'foo'
- G
-
- bundle! :install, :artifice => "compact_index_api_missing"
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- 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"
- end
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra"
- gem "back_deps"
- 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 "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}"
-
- gem "bundler_dep"
- G
-
- bundle! :install, :artifice => "compact_index"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- end
-
- it "should install when EndpointSpecification has a bin dir owned by root", :sudo => true do
- sudo "mkdir -p #{system_gem_path("bin")}"
- sudo "chown -R root #{system_gem_path("bin")}"
-
- gemfile <<-G
- source "#{source_uri}"
- gem "rails"
- G
- bundle! :install, :artifice => "compact_index"
- expect(the_bundle).to include_gems "rails 2.3.2"
- end
-
- it "installs the binstubs", :bundler => "< 2" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --binstubs", :artifice => "compact_index"
-
- gembin "rackup"
- expect(out).to eq("1.0.0")
- end
-
- it "installs the bins when using --path and uses autoclean", :bundler => "< 2" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --path vendor/bundle", :artifice => "compact_index"
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "installs the bins when using --path and uses bundle clean", :bundler => "< 2" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --path vendor/bundle --no-clean", :artifice => "compact_index"
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "prints post_install_messages" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack-obama'
- G
-
- bundle! :install, :artifice => "compact_index"
- expect(out).to include("Post-install message from rack:")
- end
-
- it "should display the post install message for a dependency" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack_middleware'
- G
-
- bundle! :install, :artifice => "compact_index"
- expect(out).to include("Post-install message from rack:")
- expect(out).to include("Rack's post install message")
- end
-
- context "when using basic authentication" do
- let(:user) { "user" }
- let(:password) { "pass" }
- let(:basic_auth_source_uri) do
- uri = URI.parse(source_uri)
- uri.user = user
- uri.password = password
-
- uri
- end
-
- it "passes basic authentication details and strips out creds" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index_basic_authentication"
- expect(out).not_to include("#{user}:#{password}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "strips http basic authentication creds for modern index" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "endopint_marshal_fail_basic_authentication"
- expect(out).not_to include("#{user}:#{password}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "strips http basic auth creds when it can't reach the server" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_500"
- expect(out).not_to include("#{user}:#{password}")
- end
-
- 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}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index_basic_authentication"
- expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(out).not_to include("#{user}:#{password}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "does not pass the user / password to different hosts on redirect" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index_creds_diff_host"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- describe "with authentication details in bundle config" do
- before do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
- end
-
- it "reads authentication details by host name from bundle config" do
- bundle "config #{source_hostname} #{user}:#{password}"
-
- bundle! :install, :artifice => "compact_index_strict_basic_authentication"
-
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "reads authentication details by full url from bundle config" do
- # The trailing slash is necessary here; Fetcher canonicalizes the URI.
- bundle "config #{source_uri}/ #{user}:#{password}"
-
- bundle! :install, :artifice => "compact_index_strict_basic_authentication"
-
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "should use the API" do
- bundle "config #{source_hostname} #{user}:#{password}"
- bundle! :install, :artifice => "compact_index_strict_basic_authentication"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "prefers auth supplied in the source uri" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle "config #{source_hostname} otheruser:wrong"
-
- bundle! :install, :artifice => "compact_index_strict_basic_authentication"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "shows instructions if auth is not provided for the source" do
- bundle :install, :artifice => "compact_index_strict_basic_authentication"
- expect(out).to include("bundle config #{source_hostname} username:password")
- end
-
- it "fails if authentication has already been provided, but failed" do
- bundle "config #{source_hostname} #{user}:wrong"
-
- bundle :install, :artifice => "compact_index_strict_basic_authentication"
- expect(out).to include("Bad username or password")
- end
- end
-
- describe "with no password" do
- let(:password) { nil }
-
- it "passes basic authentication details" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index_basic_authentication"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
- end
-
- 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
- # we can't just overwrite openssl.rb is that Artifice uses it.
- bundled_app("broken_ssl").mkpath
- bundled_app("broken_ssl/openssl.rb").open("w") do |f|
- f.write <<-RUBY
- raise LoadError, "cannot load such file -- openssl"
- RUBY
- end
- end
-
- it "explains what to do to get it" do
- gemfile <<-G
- source "#{source_uri.gsub(/http/, "https")}"
- gem "rack"
- G
-
- bundle :install, :env => { "RUBYOPT" => "-I#{bundled_app("broken_ssl")}" }
- expect(out).to include("OpenSSL")
- end
- end
-
- 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.
- gemfile <<-G
- class Net::HTTP
- def start
- raise OpenSSL::SSL::SSLError, "certificate verify failed"
- end
- end
-
- source "#{source_uri.gsub(/http/, "https")}"
- gem "rack"
- G
-
- bundle :install
- expect(out).to match(/could not verify the SSL certificate/i)
- end
- end
-
- context ".gemrc with sources is present" do
- before do
- File.open(home(".gemrc"), "w") do |file|
- file.puts({ :sources => ["https://rubygems.org"] }.to_yaml)
- end
- end
-
- after do
- home(".gemrc").rmtree
- end
-
- it "uses other sources declared in the Gemfile" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack'
- G
-
- bundle! :install, :artifice => "compact_index_forbidden"
- end
- end
-
- it "performs partial update with a non-empty range" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack', '0.9.1'
- G
-
- # Initial install creates the cached versions file
- bundle! :install, :artifice => "compact_index"
-
- # Update the Gemfile so we can check subsequent install was successful
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack', '1.0.0'
- G
-
- # Second install should make only a partial request to /versions
- bundle! :install, :artifice => "compact_index_partial_update"
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "performs partial update while local cache is updated by another process" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack'
- G
-
- # Create an empty file to trigger a partial download
- versions = File.join(Bundler.rubygems.user_home, ".bundle", "cache", "compact_index",
- "localgemserver.test.80.dd34752a738ee965a2a4298dc16db6c5", "versions")
- FileUtils.mkdir_p(File.dirname(versions))
- FileUtils.touch(versions)
-
- bundle! :install, :artifice => "compact_index_concurrent_download"
-
- expect(File.read(versions)).to start_with("created_at")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "fails gracefully when the source URI has an invalid scheme" do
- install_gemfile <<-G
- source "htps://rubygems.org"
- gem "rack"
- G
- expect(exitstatus).to eq(15) if exitstatus
- expect(out).to end_with(<<-E.strip)
- The request uri `htps://index.rubygems.org/versions` has an invalid scheme (`htps`). Did you mean `http` or `https`?
- E
- end
-
- describe "checksum validation", :rubygems => ">= 2.3.0" do
- it "raises when the checksum does not match" do
- install_gemfile <<-G, :artifice => "compact_index_wrong_gem_checksum"
- source "#{source_uri}"
- gem "rack"
- G
-
- expect(exitstatus).to eq(19) if exitstatus
- expect(out).
- to include("Bundler cannot continue installing rack (1.0.0).").
- 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: `#{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").
- and include("2. run `bundle install`").
- and match(/\(More info: The expected SHA256 checksum was "#{"ab" * 22}", but the checksum for the downloaded gem was ".+?"\.\)/)
- end
-
- it "raises when the checksum is the wrong length" do
- install_gemfile <<-G, :artifice => "compact_index_wrong_gem_checksum", :env => { "BUNDLER_SPEC_RACK_CHECKSUM" => "checksum!" }
- source "#{source_uri}"
- gem "rack"
- G
- expect(exitstatus).to eq(5) if exitstatus
- expect(out).to include("The given checksum for rack-1.0.0 (\"checksum!\") is not a valid SHA256 hexdigest nor base64digest")
- end
-
- it "does not raise when disable_checksum_validation is set" do
- bundle! "config disable_checksum_validation true"
- install_gemfile! <<-G, :artifice => "compact_index_wrong_gem_checksum"
- source "#{source_uri}"
- gem "rack"
- G
- end
- end
-
- it "works when cache dir is world-writable" do
- install_gemfile! <<-G, :artifice => "compact_index"
- File.umask(0000)
- source "#{source_uri}"
- gem "rack"
- G
- end
-
- it "doesn't explode when the API dependencies are wrong" do
- install_gemfile <<-G, :artifice => "compact_index_wrong_dependencies", :env => { "DEBUG" => "true" }
- source "#{source_uri}"
- gem "rails"
- G
- deps = [Gem::Dependency.new("rake", "= 10.0.2"),
- Gem::Dependency.new("actionpack", "= 2.3.2"),
- Gem::Dependency.new("activerecord", "= 2.3.2"),
- Gem::Dependency.new("actionmailer", "= 2.3.2"),
- Gem::Dependency.new("activeresource", "= 2.3.2")]
- expect(out).to include(<<-E.strip).and include("rails-2.3.2 from rubygems remote at #{source_uri}/ has either corrupted API or lockfile dependencies")
-Bundler::APIResponseMismatchError: Downloading rails-2.3.2 revealed dependencies not in the API or the lockfile (#{deps.map(&:to_s).join(", ")}).
-Either installing with `--full-index` or running `bundle update rails` should fix the problem.
- E
- end
-
- it "does not duplicate specs in the lockfile when updating and a dependency is not installed" do
- install_gemfile! <<-G, :artifice => "compact_index"
- source "#{source_uri}" do
- gem "rails"
- gem "activemerchant"
- end
- G
- gem_command! :uninstall, "activemerchant"
- bundle! "update rails", :artifice => "compact_index"
- expect(lockfile.scan(/activemerchant \(/).size).to eq(1)
- end
-end
diff --git a/spec/bundler/install/gems/dependency_api_spec.rb b/spec/bundler/install/gems/dependency_api_spec.rb
deleted file mode 100644
index fe696f38c3..0000000000
--- a/spec/bundler/install/gems/dependency_api_spec.rb
+++ /dev/null
@@ -1,760 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "gemcutter's dependency API" do
- let(:source_hostname) { "localgemserver.test" }
- let(:source_uri) { "http://#{source_hostname}" }
-
- it "should use the API" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "should URI encode gem names" do
- gemfile <<-G
- source "#{source_uri}"
- gem " sinatra"
- G
-
- bundle :install, :artifice => "endpoint"
- expect(out).to include("' sinatra' is not a valid gem name because it contains whitespace.")
- end
-
- it "should handle nested dependencies" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rails"
- G
-
- bundle :install, :artifice => "endpoint"
- expect(out).to include("Fetching gem metadata from #{source_uri}/...")
- expect(the_bundle).to include_gems(
- "rails 2.3.2",
- "actionpack 2.3.2",
- "activerecord 2.3.2",
- "actionmailer 2.3.2",
- "activeresource 2.3.2",
- "activesupport 2.3.2"
- )
- end
-
- it "should handle multiple gem dependencies on the same gem" do
- gemfile <<-G
- source "#{source_uri}"
- gem "net-sftp"
- G
-
- bundle :install, :artifice => "endpoint"
- expect(the_bundle).to include_gems "net-sftp 1.1.1"
- end
-
- it "should use the endpoint when using --deployment" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
- bundle :install, :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
-
- it "handles git dependencies that are in rubygems" do
- build_git "foo" do |s|
- s.executables = "foobar"
- s.add_dependency "rails", "2.3.2"
- end
-
- gemfile <<-G
- source "#{source_uri}"
- git "file:///#{lib_path("foo-1.0")}" do
- gem 'foo'
- end
- G
-
- bundle :install, :artifice => "endpoint"
-
- expect(the_bundle).to include_gems("rails 2.3.2")
- end
-
- it "handles git dependencies that are in rubygems using --deployment" do
- build_git "foo" do |s|
- s.executables = "foobar"
- s.add_dependency "rails", "2.3.2"
- end
-
- gemfile <<-G
- source "#{source_uri}"
- gem 'foo', :git => "file:///#{lib_path("foo-1.0")}"
- G
-
- bundle :install, :artifice => "endpoint"
-
- bundle "install --deployment", :artifice => "endpoint"
-
- expect(the_bundle).to include_gems("rails 2.3.2")
- end
-
- it "doesn't fail if you only have a git gem with no deps when using --deployment" do
- build_git "foo"
- gemfile <<-G
- source "#{source_uri}"
- gem 'foo', :git => "file:///#{lib_path("foo-1.0")}"
- G
-
- bundle "install", :artifice => "endpoint"
- bundle! :install, forgotten_command_line_options(:deployment => true).merge(:artifice => "endpoint")
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
-
- it "falls back when the API errors out" do
- simulate_platform mswin
-
- gemfile <<-G
- source "#{source_uri}"
- gem "rcov"
- G
-
- bundle :install, :artifice => "windows"
- expect(out).to include("Fetching source index from #{source_uri}")
- expect(the_bundle).to include_gems "rcov 1.0.0"
- end
-
- it "falls back when hitting the Gemcutter Dependency Limit" do
- gemfile <<-G
- source "#{source_uri}"
- gem "activesupport"
- gem "actionpack"
- gem "actionmailer"
- gem "activeresource"
- gem "thin"
- gem "rack"
- gem "rails"
- G
- bundle :install, :artifice => "endpoint_fallback"
- expect(out).to include("Fetching source index from #{source_uri}")
-
- expect(the_bundle).to include_gems(
- "activesupport 2.3.2",
- "actionpack 2.3.2",
- "actionmailer 2.3.2",
- "activeresource 2.3.2",
- "activesupport 2.3.2",
- "thin 1.0.0",
- "rack 1.0.0",
- "rails 2.3.2"
- )
- end
-
- it "falls back when Gemcutter API doesn't return proper Marshal format" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle :install, :verbose => true, :artifice => "endpoint_marshal_fail"
- expect(out).to include("could not fetch from the dependency API, trying the full index")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "falls back when the API URL returns 403 Forbidden" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle :install, :verbose => true, :artifice => "endpoint_api_forbidden"
- expect(out).to include("Fetching source index from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "handles host redirects" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_host_redirect"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "handles host redirects without Net::HTTP::Persistent" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- FileUtils.mkdir_p lib_path
- File.open(lib_path("disable_net_http_persistent.rb"), "w") do |h|
- h.write <<-H
- module Kernel
- alias require_without_disabled_net_http require
- def require(*args)
- raise LoadError, 'simulated' if args.first == 'openssl' && !caller.grep(/vendored_persistent/).empty?
- require_without_disabled_net_http(*args)
- end
- end
- H
- end
-
- bundle :install, :artifice => "endpoint_host_redirect", :requires => [lib_path("disable_net_http_persistent.rb")]
- expect(out).to_not match(/Too many redirects/)
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "timeouts when Bundler::Fetcher redirects too much" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_redirect"
- expect(out).to match(/Too many redirects/)
- end
-
- context "when --full-index is specified" do
- it "should use the modern index for install" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --full-index", :artifice => "endpoint"
- expect(out).to include("Fetching source index from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "should use the modern index for update" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- 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", :bundler => "< 2" 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"
- gem "back_deps"
- G
-
- bundle :install, :artifice => "endpoint_extra"
- 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
- gemfile <<-G
- source "#{source_uri}"
- gem "rack", "1.0.0"
- G
- bundle :install, :artifice => "endpoint_extra_api"
-
- build_repo4 do
- build_gem "rack", "1.2" do |s|
- s.executables = "rackup"
- end
- end
-
- gemfile <<-G
- source "#{source_uri}" do; end
- source "#{source_uri}/extra"
- gem "rack", "1.2"
- G
- bundle :install, :artifice => "endpoint_extra_api"
- expect(the_bundle).to include_gems "rack 1.2"
- end
-
- 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
- # 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"
- 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"
- 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|
- 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(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", :bundler => "< 2" 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"
- gem "back_deps"
- G
-
- bundle :install, :artifice => "endpoint_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 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}"
-
- gem 'foo'
- G
-
- bundle :install, :artifice => "endpoint_api_missing"
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- 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"
- end
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra"
- gem "back_deps"
- G
-
- bundle :install, :artifice => "endpoint_extra"
-
- bundle "install --deployment", :artifice => "endpoint_extra"
- 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}"
-
- gem "bundler_dep"
- G
-
- bundle :install, :artifice => "endpoint"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- end
-
- it "should install when EndpointSpecification has a bin dir owned by root", :sudo => true do
- sudo "mkdir -p #{system_gem_path("bin")}"
- sudo "chown -R root #{system_gem_path("bin")}"
-
- gemfile <<-G
- source "#{source_uri}"
- gem "rails"
- G
- bundle :install, :artifice => "endpoint"
- expect(the_bundle).to include_gems "rails 2.3.2"
- end
-
- it "installs the binstubs", :bundler => "< 2" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --binstubs", :artifice => "endpoint"
-
- gembin "rackup"
- expect(out).to eq("1.0.0")
- end
-
- it "installs the bins when using --path and uses autoclean", :bundler => "< 2" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --path vendor/bundle", :artifice => "endpoint"
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "installs the bins when using --path and uses bundle clean", :bundler => "< 2" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --path vendor/bundle --no-clean", :artifice => "endpoint"
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "prints post_install_messages" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack-obama'
- G
-
- bundle :install, :artifice => "endpoint"
- expect(out).to include("Post-install message from rack:")
- end
-
- it "should display the post install message for a dependency" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack_middleware'
- G
-
- bundle :install, :artifice => "endpoint"
- expect(out).to include("Post-install message from rack:")
- expect(out).to include("Rack's post install message")
- end
-
- context "when using basic authentication" do
- let(:user) { "user" }
- let(:password) { "pass" }
- let(:basic_auth_source_uri) do
- uri = URI.parse(source_uri)
- uri.user = user
- uri.password = password
-
- uri
- end
-
- it "passes basic authentication details and strips out creds" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_basic_authentication"
- expect(out).not_to include("#{user}:#{password}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "strips http basic authentication creds for modern index" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endopint_marshal_fail_basic_authentication"
- expect(out).not_to include("#{user}:#{password}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "strips http basic auth creds when it can't reach the server" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_500"
- expect(out).not_to include("#{user}:#{password}")
- end
-
- 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}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_basic_authentication"
- expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(out).not_to include("#{user}:#{password}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "does not pass the user / password to different hosts on redirect" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_creds_diff_host"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- describe "with authentication details in bundle config" do
- before do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
- end
-
- it "reads authentication details by host name from bundle config" do
- bundle "config #{source_hostname} #{user}:#{password}"
-
- bundle :install, :artifice => "endpoint_strict_basic_authentication"
-
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "reads authentication details by full url from bundle config" do
- # The trailing slash is necessary here; Fetcher canonicalizes the URI.
- bundle "config #{source_uri}/ #{user}:#{password}"
-
- bundle :install, :artifice => "endpoint_strict_basic_authentication"
-
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "should use the API" do
- bundle "config #{source_hostname} #{user}:#{password}"
- bundle :install, :artifice => "endpoint_strict_basic_authentication"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "prefers auth supplied in the source uri" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle "config #{source_hostname} otheruser:wrong"
-
- bundle :install, :artifice => "endpoint_strict_basic_authentication"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "shows instructions if auth is not provided for the source" do
- bundle :install, :artifice => "endpoint_strict_basic_authentication"
- expect(out).to include("bundle config #{source_hostname} username:password")
- end
-
- it "fails if authentication has already been provided, but failed" do
- bundle "config #{source_hostname} #{user}:wrong"
-
- bundle :install, :artifice => "endpoint_strict_basic_authentication"
- expect(out).to include("Bad username or password")
- end
- end
-
- describe "with no password" do
- let(:password) { nil }
-
- it "passes basic authentication details" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_basic_authentication"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
- end
-
- 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
- # we can't just overwrite openssl.rb is that Artifice uses it.
- bundled_app("broken_ssl").mkpath
- bundled_app("broken_ssl/openssl.rb").open("w") do |f|
- f.write <<-RUBY
- raise LoadError, "cannot load such file -- openssl"
- RUBY
- end
- end
-
- it "explains what to do to get it" do
- gemfile <<-G
- source "#{source_uri.gsub(/http/, "https")}"
- gem "rack"
- G
-
- bundle :install, :env => { "RUBYOPT" => "-I#{bundled_app("broken_ssl")}" }
- expect(out).to include("OpenSSL")
- end
- end
-
- 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.
- gemfile <<-G
- class Net::HTTP
- def start
- raise OpenSSL::SSL::SSLError, "certificate verify failed"
- end
- end
-
- source "#{source_uri.gsub(/http/, "https")}"
- gem "rack"
- G
-
- bundle :install
- expect(out).to match(/could not verify the SSL certificate/i)
- end
- end
-
- context ".gemrc with sources is present" do
- before do
- File.open(home(".gemrc"), "w") do |file|
- file.puts({ :sources => ["https://rubygems.org"] }.to_yaml)
- end
- end
-
- after do
- home(".gemrc").rmtree
- end
-
- it "uses other sources declared in the Gemfile" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack'
- G
-
- bundle "install", :artifice => "endpoint_marshal_fail"
-
- expect(exitstatus).to eq(0) if exitstatus
- end
- end
-end
diff --git a/spec/bundler/install/gems/env_spec.rb b/spec/bundler/install/gems/env_spec.rb
deleted file mode 100644
index 0dccbbfd24..0000000000
--- a/spec/bundler/install/gems/env_spec.rb
+++ /dev/null
@@ -1,107 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with ENV conditionals" do
- describe "when just setting an ENV key as a string" do
- before :each do
- gemfile <<-G
- source "file://#{gem_repo1}"
-
- env "BUNDLER_TEST" do
- gem "rack"
- end
- G
- end
-
- it "excludes the gems when the ENV variable is not set" do
- bundle :install
- expect(the_bundle).not_to include_gems "rack"
- end
-
- it "includes the gems when the ENV variable is set" do
- ENV["BUNDLER_TEST"] = "1"
- bundle :install
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- describe "when just setting an ENV key as a symbol" do
- before :each do
- gemfile <<-G
- source "file://#{gem_repo1}"
-
- env :BUNDLER_TEST do
- gem "rack"
- end
- G
- end
-
- it "excludes the gems when the ENV variable is not set" do
- bundle :install
- expect(the_bundle).not_to include_gems "rack"
- end
-
- it "includes the gems when the ENV variable is set" do
- ENV["BUNDLER_TEST"] = "1"
- bundle :install
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- describe "when setting a string to match the env" do
- before :each do
- gemfile <<-G
- source "file://#{gem_repo1}"
-
- env "BUNDLER_TEST" => "foo" do
- gem "rack"
- end
- G
- end
-
- it "excludes the gems when the ENV variable is not set" do
- bundle :install
- expect(the_bundle).not_to include_gems "rack"
- end
-
- it "excludes the gems when the ENV variable is set but does not match the condition" do
- ENV["BUNDLER_TEST"] = "1"
- bundle :install
- expect(the_bundle).not_to include_gems "rack"
- end
-
- it "includes the gems when the ENV variable is set and matches the condition" do
- ENV["BUNDLER_TEST"] = "foo"
- bundle :install
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- describe "when setting a regex to match the env" do
- before :each do
- gemfile <<-G
- source "file://#{gem_repo1}"
-
- env "BUNDLER_TEST" => /foo/ do
- gem "rack"
- end
- G
- end
-
- it "excludes the gems when the ENV variable is not set" do
- bundle :install
- expect(the_bundle).not_to include_gems "rack"
- end
-
- it "excludes the gems when the ENV variable is set but does not match the condition" do
- ENV["BUNDLER_TEST"] = "fo"
- bundle :install
- expect(the_bundle).not_to include_gems "rack"
- end
-
- it "includes the gems when the ENV variable is set and matches the condition" do
- ENV["BUNDLER_TEST"] = "foobar"
- bundle :install
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-end
diff --git a/spec/bundler/install/gems/flex_spec.rb b/spec/bundler/install/gems/flex_spec.rb
deleted file mode 100644
index f8b40f8e4e..0000000000
--- a/spec/bundler/install/gems/flex_spec.rb
+++ /dev/null
@@ -1,351 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle flex_install" do
- it "installs the gems as expected" do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'rack'
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(the_bundle).to be_locked
- end
-
- it "installs even when the lockfile is invalid" do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'rack'
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(the_bundle).to be_locked
-
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'rack', '1.0'
- G
-
- bundle :install
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(the_bundle).to be_locked
- end
-
- it "keeps child dependencies at the same version" do
- build_repo2
-
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem "rack-obama"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0", "rack-obama 1.0.0"
-
- update_repo2
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem "rack-obama", "1.0"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0", "rack-obama 1.0.0"
- end
-
- describe "adding new gems" do
- it "installs added gems without updating previously installed gems" do
- build_repo2
-
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem 'rack'
- G
-
- update_repo2
-
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem 'rack'
- gem 'activesupport', '2.3.5'
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.5"
- end
-
- it "keeps child dependencies pinned" do
- build_repo2
-
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem "rack-obama"
- G
-
- update_repo2
-
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem "rack-obama"
- gem "thin"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0", "rack-obama 1.0", "thin 1.0"
- end
- end
-
- describe "removing gems" do
- it "removes gems without changing the versions of remaining gems" do
- build_repo2
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem 'rack'
- gem 'activesupport', '2.3.5'
- G
-
- update_repo2
-
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem 'rack'
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(the_bundle).not_to include_gems "activesupport 2.3.5"
-
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem 'rack'
- gem 'activesupport', '2.3.2'
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.2"
- end
-
- it "removes top level dependencies when removed from the Gemfile while leaving other dependencies intact" do
- build_repo2
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem 'rack'
- gem 'activesupport', '2.3.5'
- G
-
- update_repo2
-
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem 'rack'
- G
-
- expect(the_bundle).not_to include_gems "activesupport 2.3.5"
- end
-
- it "removes child dependencies" do
- build_repo2
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem 'rack-obama'
- gem 'activesupport'
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0", "rack-obama 1.0.0", "activesupport 2.3.5"
-
- update_repo2
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem 'activesupport'
- G
-
- expect(the_bundle).to include_gems "activesupport 2.3.5"
- expect(the_bundle).not_to include_gems "rack-obama", "rack"
- end
- end
-
- describe "when Gemfile conflicts with lockfile" do
- before(:each) do
- build_repo2
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem "rack_middleware"
- G
-
- expect(the_bundle).to include_gems "rack_middleware 1.0", "rack 0.9.1"
-
- build_repo2
- update_repo2 do
- build_gem "rack-obama", "2.0" do |s|
- s.add_dependency "rack", "=1.2"
- end
- build_gem "rack_middleware", "2.0" do |s|
- s.add_dependency "rack", ">=1.0"
- end
- end
-
- gemfile <<-G
- source "file://#{gem_repo2}"
- gem "rack-obama", "2.0"
- gem "rack_middleware"
- G
- end
-
- it "does not install gems whose dependencies are not met" do
- bundle :install
- ruby <<-RUBY
- require 'bundler/setup'
- RUBY
- expect(err).to match(/could not find gem 'rack-obama/i)
- end
-
- it "suggests bundle update when the Gemfile requires different versions than the lock" do
- nice_error = <<-E.strip.gsub(/^ {8}/, "")
- Bundler could not find compatible versions for gem "rack":
- In snapshot (Gemfile.lock):
- rack (= 0.9.1)
-
- In Gemfile:
- rack-obama (= 2.0) was resolved to 2.0, which depends on
- rack (= 1.2)
-
- rack_middleware was resolved to 1.0, which depends on
- rack (= 0.9.1)
-
- Running `bundle update` will rebuild your snapshot from scratch, using only
- the gems in your Gemfile, which may resolve the conflict.
- E
-
- bundle :install, :retry => 0
- expect(last_command.bundler_err).to end_with(nice_error)
- end
- end
-
- describe "subtler cases" do
- before :each do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- gem "rack-obama"
- G
-
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack", "0.9.1"
- gem "rack-obama"
- G
- end
-
- it "does something" do
- expect do
- bundle "install"
- end.not_to change { File.read(bundled_app("Gemfile.lock")) }
-
- expect(out).to include("rack = 0.9.1")
- expect(out).to include("locked at 1.0.0")
- expect(out).to include("bundle update rack")
- end
-
- it "should work when you update" do
- bundle "update rack"
- end
- end
-
- describe "when adding a new source" do
- it "updates the lockfile", :bundler => "< 2" do
- build_repo2
- install_gemfile! <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack"
- G
- install_gemfile! <<-G
- source "file://localhost#{gem_repo1}"
- source "file://localhost#{gem_repo2}"
- gem "rack"
- G
-
- lockfile_should_be <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- remote: file://localhost#{gem_repo2}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{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
- describe "when a locked child dependency conflicts" do
- before(:each) do
- build_repo2 do
- build_gem "capybara", "0.3.9" do |s|
- s.add_dependency "rack", ">= 1.0.0"
- end
-
- build_gem "rack", "1.1.0"
- build_gem "rails", "3.0.0.rc4" do |s|
- s.add_dependency "rack", "~> 1.1.0"
- end
-
- build_gem "rack", "1.2.1"
- build_gem "rails", "3.0.0" do |s|
- s.add_dependency "rack", "~> 1.2.1"
- end
- end
- end
-
- it "prints the correct error message" do
- # install Rails 3.0.0.rc
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem "rails", "3.0.0.rc4"
- gem "capybara", "0.3.9"
- G
-
- # upgrade Rails to 3.0.0 and then install again
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem "rails", "3.0.0"
- gem "capybara", "0.3.9"
- G
-
- expect(out).to include("Gemfile.lock")
- end
- end
-end
diff --git a/spec/bundler/install/gems/mirror_spec.rb b/spec/bundler/install/gems/mirror_spec.rb
deleted file mode 100644
index 89302615f1..0000000000
--- a/spec/bundler/install/gems/mirror_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with a mirror configured" do
- describe "when the mirror does not match the gem source" do
- before :each do
- gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
- bundle "config --local mirror.http://gems.example.org http://gem-mirror.example.org"
- end
-
- it "installs from the normal location" do
- bundle :install
- expect(out).to include("Fetching source index from file://localhost#{gem_repo1}")
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- describe "when the gem source matches a configured mirror" do
- before :each do
- gemfile <<-G
- # This source is bogus and doesn't have the gem we're looking for
- source "file://localhost#{gem_repo2}"
-
- gem "rack"
- G
- bundle "config --local mirror.file://localhost#{gem_repo2} file://localhost#{gem_repo1}"
- end
-
- it "installs the gem from the mirror" do
- bundle :install
- expect(out).to include("Fetching source index from file://localhost#{gem_repo1}")
- expect(out).not_to include("Fetching source index from file://localhost#{gem_repo2}")
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-end
diff --git a/spec/bundler/install/gems/native_extensions_spec.rb b/spec/bundler/install/gems/native_extensions_spec.rb
deleted file mode 100644
index ea616f60d3..0000000000
--- a/spec/bundler/install/gems/native_extensions_spec.rb
+++ /dev/null
@@ -1,90 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "installing a gem with native extensions", :ruby_repo do
- it "installs" do
- build_repo2 do
- build_gem "c_extension" do |s|
- s.extensions = ["ext/extconf.rb"]
- s.write "ext/extconf.rb", <<-E
- require "mkmf"
- name = "c_extension_bundle"
- dir_config(name)
- raise "OMG" unless with_config("c_extension") == "hello"
- create_makefile(name)
- E
-
- s.write "ext/c_extension.c", <<-C
- #include "ruby.h"
-
- VALUE c_extension_true(VALUE self) {
- return Qtrue;
- }
-
- void Init_c_extension_bundle() {
- VALUE c_Extension = rb_define_class("CExtension", rb_cObject);
- rb_define_method(c_Extension, "its_true", c_extension_true, 0);
- }
- C
-
- s.write "lib/c_extension.rb", <<-C
- require "c_extension_bundle"
- C
- end
- end
-
- gemfile <<-G
- source "file://#{gem_repo2}"
- gem "c_extension"
- G
-
- bundle "config build.c_extension --with-c_extension=hello"
- bundle "install"
-
- expect(out).not_to include("extconf.rb failed")
- expect(out).to include("Installing c_extension 1.0 with native extensions")
-
- run "Bundler.require; puts CExtension.new.its_true"
- expect(out).to eq("true")
- end
-
- it "installs from git" do
- build_git "c_extension" do |s|
- s.extensions = ["ext/extconf.rb"]
- s.write "ext/extconf.rb", <<-E
- require "mkmf"
- name = "c_extension_bundle"
- dir_config(name)
- raise "OMG" unless with_config("c_extension") == "hello"
- create_makefile(name)
- E
-
- s.write "ext/c_extension.c", <<-C
- #include "ruby.h"
-
- VALUE c_extension_true(VALUE self) {
- return Qtrue;
- }
-
- void Init_c_extension_bundle() {
- VALUE c_Extension = rb_define_class("CExtension", rb_cObject);
- rb_define_method(c_Extension, "its_true", c_extension_true, 0);
- }
- C
-
- s.write "lib/c_extension.rb", <<-C
- require "c_extension_bundle"
- C
- end
-
- bundle! "config build.c_extension --with-c_extension=hello"
-
- install_gemfile! <<-G
- gem "c_extension", :git => #{lib_path("c_extension-1.0").to_s.dump}
- G
-
- expect(out).not_to include("extconf.rb failed")
-
- run! "Bundler.require; puts CExtension.new.its_true"
- expect(out).to eq("true")
- end
-end
diff --git a/spec/bundler/install/gems/post_install_spec.rb b/spec/bundler/install/gems/post_install_spec.rb
deleted file mode 100644
index c6e348fb65..0000000000
--- a/spec/bundler/install/gems/post_install_spec.rb
+++ /dev/null
@@ -1,150 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install" do
- context "with gem sources" do
- context "when gems include post install messages" do
- it "should display the post-install messages after installing" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'rack'
- gem 'thin'
- gem 'rack-obama'
- G
-
- bundle :install
- expect(out).to include("Post-install message from rack:")
- expect(out).to include("Rack's post install message")
- expect(out).to include("Post-install message from thin:")
- expect(out).to include("Thin's post install message")
- expect(out).to include("Post-install message from rack-obama:")
- expect(out).to include("Rack-obama's post install message")
- end
- end
-
- context "when gems do not include post install messages" do
- it "should not display any post-install messages" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "activesupport"
- G
-
- bundle :install
- expect(out).not_to include("Post-install message")
- end
- end
-
- context "when a dependecy includes a post install message" do
- it "should display the post install message" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'rack_middleware'
- G
-
- bundle :install
- expect(out).to include("Post-install message from rack:")
- expect(out).to include("Rack's post install message")
- end
- end
- end
-
- context "with git sources" do
- context "when gems include post install messages" do
- it "should display the post-install messages after installing" do
- build_git "foo" do |s|
- s.post_install_message = "Foo's post install message"
- end
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'foo', :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle :install
- expect(out).to include("Post-install message from foo:")
- expect(out).to include("Foo's post install message")
- end
-
- it "should display the post-install messages if repo is updated" do
- build_git "foo" do |s|
- s.post_install_message = "Foo's post install message"
- end
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'foo', :git => '#{lib_path("foo-1.0")}'
- G
- bundle :install
-
- build_git "foo", "1.1" do |s|
- s.post_install_message = "Foo's 1.1 post install message"
- end
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'foo', :git => '#{lib_path("foo-1.1")}'
- G
- bundle :install
-
- expect(out).to include("Post-install message from foo:")
- expect(out).to include("Foo's 1.1 post install message")
- end
-
- it "should not display the post-install messages if repo is not updated" do
- build_git "foo" do |s|
- s.post_install_message = "Foo's post install message"
- end
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'foo', :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle :install
- expect(out).to include("Post-install message from foo:")
- expect(out).to include("Foo's post install message")
-
- bundle :install
- expect(out).not_to include("Post-install message")
- end
- end
-
- context "when gems do not include post install messages" do
- it "should not display any post-install messages" do
- build_git "foo" do |s|
- s.post_install_message = nil
- end
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'foo', :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle :install
- expect(out).not_to include("Post-install message")
- end
- end
- end
-
- context "when ignore post-install messages for gem is set" do
- it "doesn't display any post-install messages" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- G
-
- bundle "config ignore_messages.rack true"
-
- bundle :install
- expect(out).not_to include("Post-install message")
- end
- end
-
- context "when ignore post-install messages for all gems" do
- it "doesn't display any post-install messages" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- G
-
- bundle "config ignore_messages true"
-
- bundle :install
- expect(out).not_to include("Post-install message")
- end
- end
-end
diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb
deleted file mode 100644
index 23e3caaefc..0000000000
--- a/spec/bundler/install/gems/resolving_spec.rb
+++ /dev/null
@@ -1,194 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with install-time dependencies" do
- it "installs gems with implicit rake dependencies", :ruby_repo do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "with_implicit_rake_dep"
- gem "another_implicit_rake_dep"
- gem "rake"
- G
-
- run <<-R
- require 'implicit_rake_dep'
- require 'another_implicit_rake_dep'
- puts IMPLICIT_RAKE_DEP
- puts ANOTHER_IMPLICIT_RAKE_DEP
- R
- expect(out).to eq("YES\nYES")
- end
-
- it "installs gems with a dependency with no type" do
- build_repo2
-
- path = "#{gem_repo2}/#{Gem::MARSHAL_SPEC_DIR}/actionpack-2.3.2.gemspec.rz"
- spec = Marshal.load(Gem.inflate(File.read(path)))
- spec.dependencies.each do |d|
- d.instance_variable_set(:@type, :fail)
- end
- File.open(path, "w") do |f|
- f.write Gem.deflate(Marshal.dump(spec))
- end
-
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem "actionpack", "2.3.2"
- G
-
- expect(the_bundle).to include_gems "actionpack 2.3.2", "activesupport 2.3.2"
- end
-
- describe "with crazy rubygem plugin stuff" do
- it "installs plugins" do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "net_b"
- G
-
- expect(the_bundle).to include_gems "net_b 1.0"
- end
-
- it "installs plugins depended on by other plugins", :ruby_repo do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "net_a"
- G
-
- expect(the_bundle).to include_gems "net_a 1.0", "net_b 1.0"
- end
-
- it "installs multiple levels of dependencies", :ruby_repo do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "net_c"
- gem "net_e"
- G
-
- expect(the_bundle).to include_gems "net_a 1.0", "net_b 1.0", "net_c 1.0", "net_d 1.0", "net_e 1.0"
- end
-
- context "with ENV['DEBUG_RESOLVER'] set" do
- it "produces debug output" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "net_c"
- gem "net_e"
- G
-
- bundle :install, :env => { "DEBUG_RESOLVER" => "1" }
-
- expect(err).to include("Creating possibility state for net_c")
- end
- end
-
- context "with ENV['DEBUG_RESOLVER_TREE'] set" do
- it "produces debug output" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "net_c"
- gem "net_e"
- G
-
- bundle :install, :env => { "DEBUG_RESOLVER_TREE" => "1" }
-
- expect(err).to include(" net_b").
- and include("Starting resolution").
- and include("Finished resolution").
- and include("Attempting to activate")
- end
- end
- end
-
- describe "when a required ruby version" do
- context "allows only an older version" do
- it "installs the older version" do
- build_repo2 do
- build_gem "rack", "9001.0.0" do |s|
- s.required_ruby_version = "> 9000"
- end
- end
-
- install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2 }
- ruby "#{RUBY_VERSION}"
- source "http://localgemserver.test/"
- gem 'rack'
- G
-
- expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000")
- expect(the_bundle).to include_gems("rack 1.2")
- end
- end
-
- context "allows no gems" do
- before do
- build_repo2 do
- build_gem "require_ruby" do |s|
- s.required_ruby_version = "> 9000"
- end
- end
- end
-
- let(:ruby_requirement) { %("#{RUBY_VERSION}") }
- let(:error_message_requirement) { "~> #{RUBY_VERSION}.0" }
-
- shared_examples_for "ruby version conflicts" do
- it "raises an error during resolution" do
- install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2 }
- source "http://localgemserver.test/"
- ruby #{ruby_requirement}
- gem 'require_ruby'
- G
-
- expect(out).to_not include("Gem::InstallError: require_ruby requires Ruby version > 9000")
-
- nice_error = strip_whitespace(<<-E).strip
- Bundler could not find compatible versions for gem "ruby\0":
- In Gemfile:
- ruby\0 (#{error_message_requirement})
-
- 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 relevant sources:
- the local ruby installation
- E
- expect(last_command.bundler_err).to end_with(nice_error)
- end
- end
-
- it_behaves_like "ruby version conflicts"
-
- describe "with a < requirement" do
- let(:ruby_requirement) { %("< 5000") }
- let(:error_message_requirement) { "< 5000" }
-
- it_behaves_like "ruby version conflicts"
- end
-
- describe "with a compound requirement" do
- let(:ruby_requirement) { %("< 5000", "> 0.1") }
- let(:error_message_requirement) { "< 5000, > 0.1" }
-
- it_behaves_like "ruby version conflicts"
- end
- end
- end
-
- describe "when a required rubygems version disallows a gem" do
- it "does not try to install those gems" do
- build_repo2 do
- build_gem "require_rubygems" do |s|
- s.required_rubygems_version = "> 9000"
- end
- end
-
- install_gemfile <<-G
- source "file://#{gem_repo2}"
- gem 'require_rubygems'
- G
-
- expect(out).to_not include("Gem::InstallError: require_rubygems requires RubyGems version > 9000")
- expect(out).to include("require_rubygems-1.0 requires rubygems version > 9000, which is incompatible with the current version, #{Gem::VERSION}")
- end
- end
-end
diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb
deleted file mode 100644
index 551f07848d..0000000000
--- a/spec/bundler/install/gems/standalone_spec.rb
+++ /dev/null
@@ -1,321 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.shared_examples "bundle install --standalone" do
- shared_examples "common functionality" do
- it "still makes the gems available to normal bundler" do
- args = expected_gems.map {|k, v| "#{k} #{v}" }
- expect(the_bundle).to include_gems(*args)
- end
-
- it "generates a bundle/bundler/setup.rb" do
- expect(bundled_app("bundle/bundler/setup.rb")).to exist
- end
-
- it "makes the gems available without bundler" do
- testrb = String.new <<-RUBY
- $:.unshift File.expand_path("bundle")
- require "bundler/setup"
-
- RUBY
- expected_gems.each do |k, _|
- testrb << "\nrequire \"#{k}\""
- testrb << "\nputs #{k.upcase}"
- end
- Dir.chdir(bundled_app) do
- ruby testrb, :no_lib => true
- end
-
- expect(out).to eq(expected_gems.values.join("\n"))
- end
-
- it "works on a different system" do
- FileUtils.mv(bundled_app, "#{bundled_app}2")
-
- testrb = String.new <<-RUBY
- $:.unshift File.expand_path("bundle")
- require "bundler/setup"
-
- RUBY
- expected_gems.each do |k, _|
- testrb << "\nrequire \"#{k}\""
- testrb << "\nputs #{k.upcase}"
- end
- Dir.chdir("#{bundled_app}2") do
- ruby testrb, :no_lib => true
- end
-
- expect(out).to eq(expected_gems.values.join("\n"))
- end
- end
-
- describe "with simple gems" do
- before do
- 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
- {
- "actionpack" => "2.3.2",
- "rails" => "2.3.2",
- }
- end
-
- include_examples "common functionality"
- end
-
- describe "with gems with native extension", :ruby_repo do
- before do
- install_gemfile <<-G, forgotten_command_line_options(:path => "bundle").merge(:standalone => true)
- source "file://#{gem_repo1}"
- gem "very_simple_binary"
- G
- end
-
- it "generates a bundle/bundler/setup.rb with the proper paths", :rubygems => "2.4" do
- extension_line = File.read(bundled_app("bundle/bundler/setup.rb")).each_line.find {|line| line.include? "/extensions/" }.strip
- expect(extension_line).to start_with '$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/'
- expect(extension_line).to end_with '/very_simple_binary-1.0"'
- end
- end
-
- describe "with gem that has an invalid gemspec" do
- before do
- build_git "bar", :gemspec => false do |s|
- s.write "lib/bar/version.rb", %(BAR_VERSION = '1.0')
- s.write "bar.gemspec", <<-G
- lib = File.expand_path('../lib/', __FILE__)
- $:.unshift lib unless $:.include?(lib)
- require 'bar/version'
-
- Gem::Specification.new do |s|
- s.name = 'bar'
- s.version = BAR_VERSION
- s.summary = 'Bar'
- s.files = Dir["lib/**/*.rb"]
- s.author = 'Anonymous'
- s.require_path = [1,2]
- end
- G
- end
- install_gemfile <<-G, forgotten_command_line_options(:path => "bundle").merge(:standalone => true)
- gem "bar", :git => "#{lib_path("bar-1.0")}"
- G
- end
-
- it "outputs a helpful error message" do
- expect(out).to include("You have one or more invalid gemspecs that need to be fixed.")
- expect(out).to include("bar 1.0 has an invalid gemspec")
- end
- end
-
- describe "with a combination of gems and git repos" do
- before do
- build_git "devise", "1.0"
-
- 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
- {
- "actionpack" => "2.3.2",
- "devise" => "1.0",
- "rails" => "2.3.2",
- }
- end
-
- include_examples "common functionality"
- end
-
- describe "with groups" do
- before do
- build_git "devise", "1.0"
-
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rails"
-
- group :test do
- gem "rspec"
- gem "rack-test"
- end
- G
- bundle! :install, forgotten_command_line_options(:path => "bundle").merge(:standalone => true)
- end
-
- let(:expected_gems) do
- {
- "actionpack" => "2.3.2",
- "rails" => "2.3.2",
- }
- end
-
- include_examples "common functionality"
-
- it "allows creating a standalone file with limited groups" do
- bundle! "install", forgotten_command_line_options(:path => "bundle").merge(:standalone => "default")
-
- Dir.chdir(bundled_app) do
- load_error_ruby <<-RUBY, "spec", :no_lib => true
- $:.unshift File.expand_path("bundle")
- require "bundler/setup"
-
- require "actionpack"
- puts ACTIONPACK
- require "spec"
- RUBY
- end
-
- 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, forgotten_command_line_options(:path => "bundle", :without => "test").merge(:standalone => true)
-
- Dir.chdir(bundled_app) do
- load_error_ruby <<-RUBY, "spec", :no_lib => true
- $:.unshift File.expand_path("bundle")
- require "bundler/setup"
-
- require "actionpack"
- puts ACTIONPACK
- require "spec"
- RUBY
- end
-
- 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", forgotten_command_line_options(:path => "path/to/bundle").merge(:standalone => true)
-
- Dir.chdir(bundled_app) do
- ruby <<-RUBY, :no_lib => true
- $:.unshift File.expand_path("path/to/bundle")
- require "bundler/setup"
-
- require "actionpack"
- puts ACTIONPACK
- RUBY
- end
-
- 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, 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
- $:.unshift File.expand_path("bundle")
- require "bundler/setup"
-
- require "actionpack"
- puts ACTIONPACK
- require "spec"
- RUBY
- end
-
- expect(last_command.stdout).to eq("2.3.2")
- expect(last_command.stderr).to eq("ZOMG LOAD ERROR")
- end
- end
-
- describe "with gemcutter's dependency API" do
- let(:source_uri) { "http://localgemserver.test" }
-
- describe "simple gems" do
- before do
- gemfile <<-G
- source "#{source_uri}"
- gem "rails"
- G
- bundle! :install, forgotten_command_line_options(:path => "bundle").merge(:standalone => true, :artifice => "endpoint")
- end
-
- let(:expected_gems) do
- {
- "actionpack" => "2.3.2",
- "rails" => "2.3.2",
- }
- end
-
- include_examples "common functionality"
- end
- end
-
- describe "with --binstubs", :bundler => "< 2" do
- before do
- 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
- {
- "actionpack" => "2.3.2",
- "rails" => "2.3.2",
- }
- end
-
- include_examples "common functionality"
-
- it "creates stubs that use the standalone load path" do
- Dir.chdir(bundled_app) do
- expect(`bin/rails -v`.chomp).to eql "2.3.2"
- end
- end
-
- it "creates stubs that can be executed from anywhere" do
- require "tmpdir"
- Dir.chdir(Dir.tmpdir) do
- sys_exec!(%(#{bundled_app("bin/rails")} -v))
- expect(out).to eq("2.3.2")
- end
- end
-
- it "creates stubs that can be symlinked" do
- pending "File.symlink is unsupported on Windows" if Bundler::WINDOWS
-
- symlink_dir = tmp("symlink")
- FileUtils.mkdir_p(symlink_dir)
- symlink = File.join(symlink_dir, "rails")
-
- File.symlink(bundled_app("bin/rails"), symlink)
- sys_exec!("#{symlink} -v")
- expect(out).to eq("2.3.2")
- end
-
- it "creates stubs with the correct load path" do
- extension_line = File.read(bundled_app("bin/rails")).each_line.find {|line| line.include? "$:.unshift" }.strip
- expect(extension_line).to eq %($:.unshift File.expand_path "../../bundle", path.realpath)
- end
- end
-end
-
-RSpec.describe "bundle install --standalone" do
- include_examples("bundle install --standalone")
-end
-
-RSpec.describe "bundle install --standalone run in a subdirectory" do
- before do
- subdir = bundled_app("bob")
- FileUtils.mkdir_p(subdir)
- Dir.chdir(subdir)
- end
-
- include_examples("bundle install --standalone")
-end
diff --git a/spec/bundler/install/gems/sudo_spec.rb b/spec/bundler/install/gems/sudo_spec.rb
deleted file mode 100644
index ae94eee9c6..0000000000
--- a/spec/bundler/install/gems/sudo_spec.rb
+++ /dev/null
@@ -1,174 +0,0 @@
-# frozen_string_literal: true
-
-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}"
- end
-
- it "installs" do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- G
-
- expect(out).to_not match(/an error occurred/i)
- expect(system_gem_path("cache/rack-1.0.0.gem")).to exist
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
- end
-
- describe "and GEM_HOME is owned by root" do
- before :each do
- bundle! "config path.system true"
- chown_system_gems_to_root
- end
-
- it "installs" do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack", '1.0'
- gem "thin"
- G
-
- expect(system_gem_path("gems/rack-1.0.0")).to exist
- expect(system_gem_path("gems/rack-1.0.0").stat.uid).to eq(0)
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "installs rake and a gem dependent on rake in the same session" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rake"
- gem "another_implicit_rake_dep"
- G
- bundle "install"
- expect(system_gem_path("gems/another_implicit_rake_dep-1.0")).to exist
- end
-
- it "installs when BUNDLE_PATH is owned by root" do
- bundle_path = tmp("owned_by_root")
- FileUtils.mkdir_p bundle_path
- sudo "chown -R root #{bundle_path}"
-
- ENV["BUNDLE_PATH"] = bundle_path.to_s
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack", '1.0'
- G
-
- expect(bundle_path.join("gems/rack-1.0.0")).to exist
- expect(bundle_path.join("gems/rack-1.0.0").stat.uid).to eq(0)
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "installs when BUNDLE_PATH does not exist" do
- root_path = tmp("owned_by_root")
- FileUtils.mkdir_p root_path
- sudo "chown -R root #{root_path}"
- bundle_path = root_path.join("does_not_exist")
-
- ENV["BUNDLE_PATH"] = bundle_path.to_s
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack", '1.0'
- G
-
- expect(bundle_path.join("gems/rack-1.0.0")).to exist
- expect(bundle_path.join("gems/rack-1.0.0").stat.uid).to eq(0)
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "installs extensions/ compiled by RubyGems 2.2", :rubygems => "2.2" do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "very_simple_binary"
- G
-
- expect(system_gem_path("gems/very_simple_binary-1.0")).to exist
- binary_glob = system_gem_path("extensions/*/*/very_simple_binary-1.0")
- expect(Dir.glob(binary_glob).first).to be
- end
- end
-
- describe "and BUNDLE_PATH is not writable" do
- before do
- sudo "chmod ugo-w #{default_bundle_path}"
- end
-
- it "installs" do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack", '1.0'
- G
-
- expect(default_bundle_path("gems/rack-1.0.0")).to exist
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "cleans up the tmpdirs generated" do
- require "tmpdir"
- Dir.glob("#{Dir.tmpdir}/bundler*").each do |tmpdir|
- FileUtils.remove_entry_secure(tmpdir)
- end
-
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- G
- tmpdirs = Dir.glob("#{Dir.tmpdir}/bundler*")
-
- expect(tmpdirs).to be_empty
- end
- end
-
- 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}"
-
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack", '1.0'
- G
-
- bundle :install, :env => { "GEM_HOME" => gem_home.to_s, "GEM_PATH" => nil }
- expect(gem_home.join("bin/rackup")).to exist
- expect(the_bundle).to include_gems "rack 1.0", :env => { "GEM_HOME" => gem_home.to_s, "GEM_PATH" => nil }
- end
- end
-
- describe "and root runs install" do
- let(:warning) { "Don't run Bundler as root." }
-
- before do
- gemfile %(source "file://#{gem_repo1}")
- end
-
- it "warns against that" do
- bundle :install, :sudo => true
- expect(out).to include(warning)
- end
-
- context "when ENV['BUNDLE_SILENCE_ROOT_WARNING'] is set" do
- it "skips the warning" do
- bundle :install, :sudo => :preserve_env, :env => { "BUNDLE_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, :env => { "BUNDLE_SILENCE_ROOT_WARNING" => "false" }
- expect(out).to include(warning)
- end
- end
- end
-end
diff --git a/spec/bundler/install/gems/win32_spec.rb b/spec/bundler/install/gems/win32_spec.rb
deleted file mode 100644
index ad758b94fa..0000000000
--- a/spec/bundler/install/gems/win32_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with win32-generated lockfile" do
- it "should read lockfile" do
- File.open(bundled_app("Gemfile.lock"), "wb") do |f|
- f << "GEM\r\n"
- f << " remote: file:#{gem_repo1}/\r\n"
- f << " specs:\r\n"
- f << "\r\n"
- f << " rack (1.0.0)\r\n"
- f << "\r\n"
- f << "PLATFORMS\r\n"
- f << " ruby\r\n"
- f << "\r\n"
- f << "DEPENDENCIES\r\n"
- f << " rack\r\n"
- end
-
- install_gemfile <<-G
- source "file://#{gem_repo1}"
-
- gem "rack"
- G
- expect(exitstatus).to eq(0) if exitstatus
- end
-end