diff options
Diffstat (limited to 'spec')
47 files changed, 269 insertions, 248 deletions
diff --git a/spec/bundler/bundler/definition_spec.rb b/spec/bundler/bundler/definition_spec.rb index 92f836299d..1f4c1a0807 100644 --- a/spec/bundler/bundler/definition_spec.rb +++ b/spec/bundler/bundler/definition_spec.rb @@ -46,7 +46,7 @@ RSpec.describe Bundler::Definition do s.add_dependency "rack", "1.0" end - bundle :install, :env => { "DEBUG" => 1 } + bundle :install, :env => { "DEBUG" => "1" } expect(out).to match(/re-resolving dependencies/) lockfile_should_be <<-G @@ -84,7 +84,7 @@ RSpec.describe Bundler::Definition do s.add_dependency "rack", "1.0" end - bundle :install, :env => { "DEBUG" => 1 } + bundle :install, :env => { "DEBUG" => "1" } expect(out).to match(/re-resolving dependencies/) lockfile_should_be <<-G @@ -121,7 +121,7 @@ RSpec.describe Bundler::Definition do gem "foo", :path => "#{lib_path("foo")}" G - bundle :check, :env => { "DEBUG" => 1 } + bundle :check, :env => { "DEBUG" => "1" } expect(out).to match(/using resolution from the lockfile/) lockfile_should_be <<-G @@ -154,7 +154,7 @@ RSpec.describe Bundler::Definition do G bundle "lock --add-platform java" - bundle :check, :env => { "DEBUG" => 1 } + bundle :check, :env => { "DEBUG" => "1" } expect(out).to match(/using resolution from the lockfile/) lockfile_should_be <<-G @@ -181,7 +181,7 @@ RSpec.describe Bundler::Definition do gem "foo" G - bundle :check, :env => { "DEBUG" => 1 } + bundle :check, :env => { "DEBUG" => "1" } expect(out).to match(/using resolution from the lockfile/) lockfile_should_be <<-G diff --git a/spec/bundler/bundler/env_spec.rb b/spec/bundler/bundler/env_spec.rb index f0ab5d5f35..7686fe386a 100644 --- a/spec/bundler/bundler/env_spec.rb +++ b/spec/bundler/bundler/env_spec.rb @@ -27,9 +27,9 @@ RSpec.describe Bundler::Env do end it "prints gem path" do - with_clear_paths("GEM_PATH", "/a/b/c:/d/e/f") do + with_clear_paths("GEM_PATH", "/a/b/c#{File::PATH_SEPARATOR}d/e/f") do out = described_class.report - expect(out).to include("Gem Path /a/b/c:/d/e/f") + expect(out).to include("Gem Path /a/b/c#{File::PATH_SEPARATOR}d/e/f") end end diff --git a/spec/bundler/bundler/fetcher/base_spec.rb b/spec/bundler/bundler/fetcher/base_spec.rb index df1245d44d..02506591f3 100644 --- a/spec/bundler/bundler/fetcher/base_spec.rb +++ b/spec/bundler/bundler/fetcher/base_spec.rb @@ -36,7 +36,7 @@ RSpec.describe Bundler::Fetcher::Base do end describe "#fetch_uri" do - let(:remote_uri_obj) { URI("http://rubygems.org") } + let(:remote_uri_obj) { Bundler::URI("http://rubygems.org") } before { allow(subject).to receive(:remote_uri).and_return(remote_uri_obj) } @@ -49,10 +49,10 @@ RSpec.describe Bundler::Fetcher::Base do end context "when the remote uri's host is not rubygems.org" do - let(:remote_uri_obj) { URI("http://otherhost.org") } + let(:remote_uri_obj) { Bundler::URI("http://otherhost.org") } it "should return the remote uri" do - expect(subject.fetch_uri).to eq(URI("http://otherhost.org")) + expect(subject.fetch_uri).to eq(Bundler::URI("http://otherhost.org")) end end diff --git a/spec/bundler/bundler/fetcher/compact_index_spec.rb b/spec/bundler/bundler/fetcher/compact_index_spec.rb index f5ae6f4d77..c9419d3eb1 100644 --- a/spec/bundler/bundler/fetcher/compact_index_spec.rb +++ b/spec/bundler/bundler/fetcher/compact_index_spec.rb @@ -2,7 +2,7 @@ RSpec.describe Bundler::Fetcher::CompactIndex do let(:downloader) { double(:downloader) } - let(:display_uri) { URI("http://sampleuri.com") } + let(:display_uri) { Bundler::URI("http://sampleuri.com") } let(:remote) { double(:remote, :cache_slug => "lsjdf", :uri => display_uri) } let(:compact_index) { described_class.new(downloader, remote, display_uri) } diff --git a/spec/bundler/bundler/fetcher/dependency_spec.rb b/spec/bundler/bundler/fetcher/dependency_spec.rb index 081fdff34d..53249116cd 100644 --- a/spec/bundler/bundler/fetcher/dependency_spec.rb +++ b/spec/bundler/bundler/fetcher/dependency_spec.rb @@ -2,7 +2,7 @@ RSpec.describe Bundler::Fetcher::Dependency do let(:downloader) { double(:downloader) } - let(:remote) { double(:remote, :uri => URI("http://localhost:5000")) } + let(:remote) { double(:remote, :uri => Bundler::URI("http://localhost:5000")) } let(:display_uri) { "http://sample_uri.com" } subject { described_class.new(downloader, remote, display_uri) } @@ -258,7 +258,7 @@ RSpec.describe Bundler::Fetcher::Dependency do end describe "#dependency_api_uri" do - let(:uri) { URI("http://gem-api.com") } + let(:uri) { Bundler::URI("http://gem-api.com") } context "with gem names" do let(:gem_names) { %w[foo bar bundler rubocop] } diff --git a/spec/bundler/bundler/fetcher/downloader_spec.rb b/spec/bundler/bundler/fetcher/downloader_spec.rb index f985b88982..ba8451d9fa 100644 --- a/spec/bundler/bundler/fetcher/downloader_spec.rb +++ b/spec/bundler/bundler/fetcher/downloader_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Bundler::Fetcher::Downloader do let(:connection) { double(:connection) } let(:redirect_limit) { 5 } - let(:uri) { URI("http://www.uri-to-fetch.com/api/v2/endpoint") } + let(:uri) { Bundler::URI("http://www.uri-to-fetch.com/api/v2/endpoint") } let(:options) { double(:options) } subject { described_class.new(connection, redirect_limit) } @@ -41,19 +41,19 @@ RSpec.describe Bundler::Fetcher::Downloader do before { http_response["location"] = "http://www.redirect-uri.com/api/v2/endpoint" } it "should try to fetch the redirect uri and iterate the # requests counter" do - expect(subject).to receive(:fetch).with(URI("http://www.uri-to-fetch.com/api/v2/endpoint"), options, 0).and_call_original - expect(subject).to receive(:fetch).with(URI("http://www.redirect-uri.com/api/v2/endpoint"), options, 1) + expect(subject).to receive(:fetch).with(Bundler::URI("http://www.uri-to-fetch.com/api/v2/endpoint"), options, 0).and_call_original + expect(subject).to receive(:fetch).with(Bundler::URI("http://www.redirect-uri.com/api/v2/endpoint"), options, 1) subject.fetch(uri, options, counter) end context "when the redirect uri and original uri are the same" do - let(:uri) { URI("ssh://username:[email protected]/api/v2/endpoint") } + let(:uri) { Bundler::URI("ssh://username:[email protected]/api/v2/endpoint") } before { http_response["location"] = "ssh://www.uri-to-fetch.com/api/v1/endpoint" } it "should set the same user and password for the redirect uri" do - expect(subject).to receive(:fetch).with(URI("ssh://username:[email protected]/api/v2/endpoint"), options, 0).and_call_original - expect(subject).to receive(:fetch).with(URI("ssh://username:[email protected]/api/v1/endpoint"), options, 1) + expect(subject).to receive(:fetch).with(Bundler::URI("ssh://username:[email protected]/api/v2/endpoint"), options, 0).and_call_original + expect(subject).to receive(:fetch).with(Bundler::URI("ssh://username:[email protected]/api/v1/endpoint"), options, 1) subject.fetch(uri, options, counter) end end @@ -84,7 +84,7 @@ RSpec.describe Bundler::Fetcher::Downloader do end context "when the there are credentials provided in the request" do - let(:uri) { URI("http://user:[email protected]") } + let(:uri) { Bundler::URI("http://user:[email protected]") } it "should raise a Bundler::Fetcher::BadAuthenticationError that doesn't contain the password" do expect { subject.fetch(uri, options, counter) }. @@ -102,7 +102,7 @@ RSpec.describe Bundler::Fetcher::Downloader do end context "when the there are credentials provided in the request" do - let(:uri) { URI("http://username:[email protected]/api/v2/endpoint") } + let(:uri) { Bundler::URI("http://username:[email protected]/api/v2/endpoint") } it "should raise a Bundler::Fetcher::FallbackError that doesn't contain the password" do expect { subject.fetch(uri, options, counter) }. @@ -137,7 +137,7 @@ RSpec.describe Bundler::Fetcher::Downloader do context "when there is a user provided in the request" do context "and there is also a password provided" do context "that contains cgi escaped characters" do - let(:uri) { URI("http://username:password%[email protected]/api/v2/endpoint") } + let(:uri) { Bundler::URI("http://username:password%[email protected]/api/v2/endpoint") } it "should request basic authentication with the username and password" do expect(net_http_get).to receive(:basic_auth).with("username", "password$") @@ -146,7 +146,7 @@ RSpec.describe Bundler::Fetcher::Downloader do end context "that is all unescaped characters" do - let(:uri) { URI("http://username:[email protected]/api/v2/endpoint") } + let(:uri) { Bundler::URI("http://username:[email protected]/api/v2/endpoint") } it "should request basic authentication with the username and proper cgi compliant password" do expect(net_http_get).to receive(:basic_auth).with("username", "password") subject.request(uri, options) @@ -155,7 +155,7 @@ RSpec.describe Bundler::Fetcher::Downloader do end context "and there is no password provided" do - let(:uri) { URI("http://[email protected]/api/v2/endpoint") } + let(:uri) { Bundler::URI("http://[email protected]/api/v2/endpoint") } it "should request basic authentication with just the user" do expect(net_http_get).to receive(:basic_auth).with("username", nil) @@ -164,7 +164,7 @@ RSpec.describe Bundler::Fetcher::Downloader do end context "that contains cgi escaped characters" do - let(:uri) { URI("http://username%[email protected]/api/v2/endpoint") } + let(:uri) { Bundler::URI("http://username%[email protected]/api/v2/endpoint") } it "should request basic authentication with the proper cgi compliant password user" do expect(net_http_get).to receive(:basic_auth).with("username$", nil) @@ -244,7 +244,7 @@ RSpec.describe Bundler::Fetcher::Downloader do end context "when the there are credentials provided in the request" do - let(:uri) { URI("http://username:[email protected]/api/v2/endpoint") } + let(:uri) { Bundler::URI("http://username:[email protected]/api/v2/endpoint") } before do allow(net_http_get).to receive(:basic_auth).with("username", "password") end diff --git a/spec/bundler/bundler/fetcher/index_spec.rb b/spec/bundler/bundler/fetcher/index_spec.rb index d5ededae3e..5ecd7d9e05 100644 --- a/spec/bundler/bundler/fetcher/index_spec.rb +++ b/spec/bundler/bundler/fetcher/index_spec.rb @@ -18,7 +18,7 @@ RSpec.describe Bundler::Fetcher::Index do context "error handling" do shared_examples_for "the error is properly handled" do - let(:remote_uri) { URI("http://remote-uri.org") } + let(:remote_uri) { Bundler::URI("http://remote-uri.org") } before do allow(subject).to receive(:remote_uri).and_return(remote_uri) end diff --git a/spec/bundler/bundler/fetcher_spec.rb b/spec/bundler/bundler/fetcher_spec.rb index 184b9efa64..539179db43 100644 --- a/spec/bundler/bundler/fetcher_spec.rb +++ b/spec/bundler/bundler/fetcher_spec.rb @@ -3,7 +3,7 @@ require "bundler/fetcher" RSpec.describe Bundler::Fetcher do - let(:uri) { URI("https://example.com") } + let(:uri) { Bundler::URI("https://example.com") } let(:remote) { double("remote", :uri => uri, :original_uri => nil) } subject(:fetcher) { Bundler::Fetcher.new(remote) } @@ -45,7 +45,7 @@ RSpec.describe Bundler::Fetcher do end context "when a rubygems source mirror is set" do - let(:orig_uri) { URI("http://zombo.com") } + let(:orig_uri) { Bundler::URI("http://zombo.com") } let(:remote_with_mirror) do double("remote", :uri => uri, :original_uri => orig_uri, :anonymized_uri => uri) end @@ -144,14 +144,14 @@ RSpec.describe Bundler::Fetcher do describe "include CI information" do it "from one CI" do with_env_vars("JENKINS_URL" => "foo") do - ci_part = fetcher.user_agent.split(" ").find {|x| x.match(%r{\Aci/}) } + ci_part = fetcher.user_agent.split(" ").find {|x| x.start_with?("ci/") } expect(ci_part).to match("jenkins") end end it "from many CI" do with_env_vars("TRAVIS" => "foo", "CI_NAME" => "my_ci") do - ci_part = fetcher.user_agent.split(" ").find {|x| x.match(%r{\Aci/}) } + ci_part = fetcher.user_agent.split(" ").find {|x| x.start_with?("ci/") } expect(ci_part).to match("travis") expect(ci_part).to match("my_ci") end diff --git a/spec/bundler/bundler/friendly_errors_spec.rb b/spec/bundler/bundler/friendly_errors_spec.rb index 47e7a5d3cd..e9189b0514 100644 --- a/spec/bundler/bundler/friendly_errors_spec.rb +++ b/spec/bundler/bundler/friendly_errors_spec.rb @@ -22,7 +22,7 @@ RSpec.describe Bundler, "friendly errors" do gem "rack" G - bundle :install, :env => { "DEBUG" => true } + bundle :install, :env => { "DEBUG" => "true" } expect(err).to include("Failed to load #{home(".gemrc")}") expect(exitstatus).to eq(0) if exitstatus diff --git a/spec/bundler/bundler/mirror_spec.rb b/spec/bundler/bundler/mirror_spec.rb index 76b697c4d2..4a8a0c7c48 100644 --- a/spec/bundler/bundler/mirror_spec.rb +++ b/spec/bundler/bundler/mirror_spec.rb @@ -36,12 +36,12 @@ RSpec.describe Bundler::Settings::Mirror do it "takes a string for the uri but returns an uri object" do mirror.uri = "http://localhost:9292" - expect(mirror.uri).to eq(URI("http://localhost:9292")) + expect(mirror.uri).to eq(Bundler::URI("http://localhost:9292")) end it "takes an uri object for the uri" do - mirror.uri = URI("http://localhost:9293") - expect(mirror.uri).to eq(URI("http://localhost:9293")) + mirror.uri = Bundler::URI("http://localhost:9293") + expect(mirror.uri).to eq(Bundler::URI("http://localhost:9293")) end context "without a uri" do @@ -145,7 +145,7 @@ RSpec.describe Bundler::Settings::Mirror do end RSpec.describe Bundler::Settings::Mirrors do - let(:localhost_uri) { URI("http://localhost:9292") } + let(:localhost_uri) { Bundler::URI("http://localhost:9292") } context "with a just created mirror" do let(:mirrors) do @@ -260,7 +260,7 @@ RSpec.describe Bundler::Settings::Mirrors do before { mirrors.parse("mirror.all.fallback_timeout", "true") } it "returns the source uri, not localhost" do - expect(mirrors.for("http://whatever.com").uri).to eq(URI("http://whatever.com/")) + expect(mirrors.for("http://whatever.com").uri).to eq(Bundler::URI("http://whatever.com/")) end end end @@ -270,7 +270,7 @@ RSpec.describe Bundler::Settings::Mirrors do context "without a fallback timeout" do it "returns the uri that is not mirrored" do - expect(mirrors.for("http://whatever.com").uri).to eq(URI("http://whatever.com/")) + expect(mirrors.for("http://whatever.com").uri).to eq(Bundler::URI("http://whatever.com/")) end it "returns localhost for rubygems.org" do @@ -282,11 +282,11 @@ RSpec.describe Bundler::Settings::Mirrors do before { mirrors.parse("mirror.http://rubygems.org/.fallback_timeout", "true") } it "returns the uri that is not mirrored" do - expect(mirrors.for("http://whatever.com").uri).to eq(URI("http://whatever.com/")) + expect(mirrors.for("http://whatever.com").uri).to eq(Bundler::URI("http://whatever.com/")) end it "returns rubygems.org for rubygems.org" do - expect(mirrors.for("http://rubygems.org/").uri).to eq(URI("http://rubygems.org/")) + expect(mirrors.for("http://rubygems.org/").uri).to eq(Bundler::URI("http://rubygems.org/")) end end end diff --git a/spec/bundler/bundler/rubygems_integration_spec.rb b/spec/bundler/bundler/rubygems_integration_spec.rb index 26cbaa630b..11fa2f4e0d 100644 --- a/spec/bundler/bundler/rubygems_integration_spec.rb +++ b/spec/bundler/bundler/rubygems_integration_spec.rb @@ -44,7 +44,7 @@ RSpec.describe Bundler::RubygemsIntegration do describe "#download_gem" do let(:bundler_retry) { double(Bundler::Retry) } let(:retry) { double("Bundler::Retry") } - let(:uri) { URI.parse("https://foo.bar") } + let(:uri) { Bundler::URI.parse("https://foo.bar") } let(:path) { Gem.path.first } let(:spec) do spec = Bundler::RemoteSpecification.new("Foo", Gem::Version.new("2.5.2"), @@ -67,13 +67,13 @@ RSpec.describe Bundler::RubygemsIntegration do end describe "#fetch_all_remote_specs" do - let(:uri) { URI("https://example.com") } + let(:uri) { "https://example.com" } let(:fetcher) { double("gem_remote_fetcher") } let(:specs_response) { Marshal.dump(["specs"]) } let(:prerelease_specs_response) { Marshal.dump(["prerelease_specs"]) } context "when a rubygems source mirror is set" do - let(:orig_uri) { URI("http://zombo.com") } + let(:orig_uri) { Bundler::URI("http://zombo.com") } let(:remote_with_mirror) { double("remote", :uri => uri, :original_uri => orig_uri) } it "sets the 'X-Gemfile-Source' header containing the original source" do diff --git a/spec/bundler/bundler/settings_spec.rb b/spec/bundler/bundler/settings_spec.rb index 2a285fdcf3..b83d768477 100644 --- a/spec/bundler/bundler/settings_spec.rb +++ b/spec/bundler/bundler/settings_spec.rb @@ -180,7 +180,7 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow end describe "#mirror_for" do - let(:uri) { URI("https://rubygems.org/") } + let(:uri) { Bundler::URI("https://rubygems.org/") } context "with no configured mirror" do it "returns the original URI" do @@ -193,7 +193,7 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow end context "with a configured mirror" do - let(:mirror_uri) { URI("https://rubygems-mirror.org/") } + let(:mirror_uri) { Bundler::URI("https://rubygems-mirror.org/") } before { settings.set_local "mirror.https://rubygems.org/", mirror_uri.to_s } @@ -214,7 +214,7 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow end context "with a file URI" do - let(:mirror_uri) { URI("file:/foo/BAR/baz/qUx/") } + let(:mirror_uri) { Bundler::URI("file:/foo/BAR/baz/qUx/") } it "returns the mirror URI" do expect(settings.mirror_for(uri)).to eq(mirror_uri) @@ -232,7 +232,7 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow end describe "#credentials_for" do - let(:uri) { URI("https://gemserver.example.org/") } + let(:uri) { Bundler::URI("https://gemserver.example.org/") } let(:credentials) { "username:password" } context "with no configured credentials" do @@ -292,7 +292,7 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow it "reads older keys without trailing slashes" do settings.set_local "mirror.https://rubygems.org", "http://rubygems-mirror.org" expect(settings.mirror_for("https://rubygems.org/")).to eq( - URI("http://rubygems-mirror.org/") + Bundler::URI("http://rubygems-mirror.org/") ) end diff --git a/spec/bundler/bundler/source/rubygems/remote_spec.rb b/spec/bundler/bundler/source/rubygems/remote_spec.rb index 52fb4e7f1c..07ce4f968e 100644 --- a/spec/bundler/bundler/source/rubygems/remote_spec.rb +++ b/spec/bundler/bundler/source/rubygems/remote_spec.rb @@ -11,8 +11,8 @@ RSpec.describe Bundler::Source::Rubygems::Remote do allow(Digest(:MD5)).to receive(:hexdigest).with(duck_type(:to_s)) {|string| "MD5HEX(#{string})" } end - let(:uri_no_auth) { URI("https://gems.example.com") } - let(:uri_with_auth) { URI("https://#{credentials}@gems.example.com") } + let(:uri_no_auth) { Bundler::URI("https://gems.example.com") } + let(:uri_with_auth) { Bundler::URI("https://#{credentials}@gems.example.com") } let(:credentials) { "username:password" } context "when the original URI has no credentials" do @@ -89,11 +89,11 @@ RSpec.describe Bundler::Source::Rubygems::Remote do end context "when the original URI has only a username" do - let(:uri) { URI("https://[email protected]/me/") } + let(:uri) { Bundler::URI("https://[email protected]/me/") } describe "#anonymized_uri" do it "returns the URI without username and password" do - expect(remote(uri).anonymized_uri).to eq(URI("https://gem.fury.io/me/")) + expect(remote(uri).anonymized_uri).to eq(Bundler::URI("https://gem.fury.io/me/")) end end @@ -105,9 +105,9 @@ RSpec.describe Bundler::Source::Rubygems::Remote do end context "when a mirror with inline credentials is configured for the URI" do - let(:uri) { URI("https://rubygems.org/") } - let(:mirror_uri_with_auth) { URI("https://username:[email protected]/") } - let(:mirror_uri_no_auth) { URI("https://rubygems-mirror.org/") } + let(:uri) { Bundler::URI("https://rubygems.org/") } + let(:mirror_uri_with_auth) { Bundler::URI("https://username:[email protected]/") } + let(:mirror_uri_no_auth) { Bundler::URI("https://rubygems-mirror.org/") } before { Bundler.settings.temporary("mirror.https://rubygems.org/" => mirror_uri_with_auth.to_s) } @@ -131,9 +131,9 @@ RSpec.describe Bundler::Source::Rubygems::Remote do end context "when a mirror with configured credentials is configured for the URI" do - let(:uri) { URI("https://rubygems.org/") } - let(:mirror_uri_with_auth) { URI("https://#{credentials}@rubygems-mirror.org/") } - let(:mirror_uri_no_auth) { URI("https://rubygems-mirror.org/") } + let(:uri) { Bundler::URI("https://rubygems.org/") } + let(:mirror_uri_with_auth) { Bundler::URI("https://#{credentials}@rubygems-mirror.org/") } + let(:mirror_uri_no_auth) { Bundler::URI("https://rubygems-mirror.org/") } before do Bundler.settings.temporary("mirror.https://rubygems.org/" => mirror_uri_no_auth.to_s) diff --git a/spec/bundler/bundler/source_list_spec.rb b/spec/bundler/bundler/source_list_spec.rb index a78b80ec3b..93159998c6 100644 --- a/spec/bundler/bundler/source_list_spec.rb +++ b/spec/bundler/bundler/source_list_spec.rb @@ -125,8 +125,8 @@ RSpec.describe Bundler::SourceList do it "adds the provided remote to the beginning of the aggregate source" do source_list.add_rubygems_remote("https://othersource.org") expect(returned_source.remotes).to eq [ - URI("https://othersource.org/"), - URI("https://rubygems.org/"), + Bundler::URI("https://othersource.org/"), + Bundler::URI("https://rubygems.org/"), ] end end diff --git a/spec/bundler/bundler/uri_credentials_filter_spec.rb b/spec/bundler/bundler/uri_credentials_filter_spec.rb index fe52d16306..466c1b8594 100644 --- a/spec/bundler/bundler/uri_credentials_filter_spec.rb +++ b/spec/bundler/bundler/uri_credentials_filter_spec.rb @@ -16,7 +16,7 @@ RSpec.describe Bundler::URICredentialsFilter do let(:credentials) { "oauth_token:x-oauth-basic@" } it "returns the uri without the oauth token" do - expect(subject.credential_filtered_uri(uri).to_s).to eq(URI("https://[email protected]/company/private-repo").to_s) + expect(subject.credential_filtered_uri(uri).to_s).to eq(Bundler::URI("https://[email protected]/company/private-repo").to_s) end it_behaves_like "original type of uri is maintained" @@ -26,7 +26,7 @@ RSpec.describe Bundler::URICredentialsFilter do let(:credentials) { "oauth_token:x@" } it "returns the uri without the oauth token" do - expect(subject.credential_filtered_uri(uri).to_s).to eq(URI("https://[email protected]/company/private-repo").to_s) + expect(subject.credential_filtered_uri(uri).to_s).to eq(Bundler::URI("https://[email protected]/company/private-repo").to_s) end it_behaves_like "original type of uri is maintained" @@ -37,7 +37,7 @@ RSpec.describe Bundler::URICredentialsFilter do let(:credentials) { "username1:hunter3@" } it "returns the uri without the password" do - expect(subject.credential_filtered_uri(uri).to_s).to eq(URI("https://[email protected]/company/private-repo").to_s) + expect(subject.credential_filtered_uri(uri).to_s).to eq(Bundler::URI("https://[email protected]/company/private-repo").to_s) end it_behaves_like "original type of uri is maintained" @@ -55,7 +55,7 @@ RSpec.describe Bundler::URICredentialsFilter do end context "uri is a uri object" do - let(:uri) { URI("https://#{credentials}github.com/company/private-repo") } + let(:uri) { Bundler::URI("https://#{credentials}github.com/company/private-repo") } it_behaves_like "sensitive credentials in uri are filtered out" end @@ -90,7 +90,7 @@ RSpec.describe Bundler::URICredentialsFilter do describe "#credential_filtered_string" do let(:str_to_filter) { "This is a git message containing a uri #{uri}!" } let(:credentials) { "" } - let(:uri) { URI("https://#{credentials}github.com/company/private-repo") } + let(:uri) { Bundler::URI("https://#{credentials}github.com/company/private-repo") } context "with a uri that contains credentials" do let(:credentials) { "oauth_token:x-oauth-basic@" } diff --git a/spec/bundler/bundler/vendored_persistent_spec.rb b/spec/bundler/bundler/vendored_persistent_spec.rb index b4d68c2ea0..3ed899dbcf 100644 --- a/spec/bundler/bundler/vendored_persistent_spec.rb +++ b/spec/bundler/bundler/vendored_persistent_spec.rb @@ -23,14 +23,14 @@ RSpec.describe Bundler::PersistentHTTP do shared_examples_for "does not warn" do it "does not warn" do allow(Bundler.ui).to receive(:warn).never - subject.warn_old_tls_version_rubygems_connection(URI(uri), connection) + subject.warn_old_tls_version_rubygems_connection(Bundler::URI(uri), connection) end end shared_examples_for "does warn" do |*expected| it "warns" do expect(Bundler.ui).to receive(:warn).with(*expected) - subject.warn_old_tls_version_rubygems_connection(URI(uri), connection) + subject.warn_old_tls_version_rubygems_connection(Bundler::URI(uri), connection) end end diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb index df10bd3498..7c04e8ddbd 100644 --- a/spec/bundler/commands/binstubs_spec.rb +++ b/spec/bundler/commands/binstubs_spec.rb @@ -458,7 +458,7 @@ RSpec.describe "bundle binstubs <gem>" do G bundle "config set auto_install 1" - bundle "binstubs rack", :env => { "BUNDLE_INSTALL" => 1 } + bundle "binstubs rack", :env => { "BUNDLE_INSTALL" => "1" } expect(out).not_to include("Installing rack 1.0.0") end end diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb index 7f9f84c104..5cc97de912 100644 --- a/spec/bundler/commands/clean_spec.rb +++ b/spec/bundler/commands/clean_spec.rb @@ -782,7 +782,7 @@ RSpec.describe "bundle clean" do expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist bundle! :clean - expect(out).to eq("") + expect(out).to be_empty expect(vendored_gems("bundler/gems/extensions")).to exist expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index 7ae504d360..a5d67c6d68 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -55,6 +55,12 @@ RSpec.describe "bundle exec" do expect(out).to eq("hi") end + it "works when exec'ing to rubygems" do + install_gemfile 'gem "rack"' + bundle "exec gem --version" + expect(out).to eq(Gem::VERSION) + end + it "respects custom process title when loading through ruby" do script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility = <<~'RUBY' Process.setproctitle("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15") @@ -98,7 +104,7 @@ RSpec.describe "bundle exec" do install_gemfile "" sys_exec "#{Gem.ruby} #{command.path}" - expect(out).to eq("") + expect(out).to be_empty expect(err).to be_empty end diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index 8e161a4aae..b57d81b10a 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -45,7 +45,7 @@ RSpec.describe "bundle install with gem sources" do gem "rack" G - bundle! :install, :env => { "BUNDLE_PATH__SYSTEM" => true } # can't use install_gemfile since it sets retry + bundle! :install, :env => { "BUNDLE_PATH__SYSTEM" => "true" } # can't use install_gemfile since it sets retry expect(bundled_app(".bundle")).not_to exist end diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb index ab54925756..6e82d34b05 100644 --- a/spec/bundler/commands/outdated_spec.rb +++ b/spec/bundler/commands/outdated_spec.rb @@ -228,7 +228,7 @@ RSpec.describe "bundle outdated" do context "and no gems are outdated" do it "has empty output" do subject - expect(out).to eq("") + expect(out).to be_empty end end end diff --git a/spec/bundler/commands/version_spec.rb b/spec/bundler/commands/version_spec.rb index f85ac82a40..8eecd9c53e 100644 --- a/spec/bundler/commands/version_spec.rb +++ b/spec/bundler/commands/version_spec.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require_relative '../support/path' +require_relative "../support/path" RSpec.describe "bundle version" do if Spec::Path.ruby_core? - COMMIT_HASH = /unknown|[a-fA-F0-9]{7,}/ + COMMIT_HASH = /unknown|[a-fA-F0-9]{7,}/.freeze else - COMMIT_HASH = /[a-fA-F0-9]{7,}/ + COMMIT_HASH = /[a-fA-F0-9]{7,}/.freeze end context "with -v" do diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb index d607f8bb46..89da3fc801 100644 --- a/spec/bundler/install/deploy_spec.rb +++ b/spec/bundler/install/deploy_spec.rb @@ -146,7 +146,7 @@ RSpec.describe "install with --deployment or --frozen" do expect(the_bundle).to include_gems "path_gem 1.0" FileUtils.rm_r lib_path("path_gem-1.0") - bundle! :install, forgotten_command_line_options(:path => ".bundle", :without => "development", :deployment => true).merge(:env => { :DEBUG => "1" }) + bundle! :install, forgotten_command_line_options(:path => ".bundle", :without => "development", :deployment => true).merge(:env => { "DEBUG" => "1" }) run! "puts :WIN" expect(out).to eq("WIN") end diff --git a/spec/bundler/install/gemfile/path_spec.rb b/spec/bundler/install/gemfile/path_spec.rb index 786b767354..e53636da09 100644 --- a/spec/bundler/install/gemfile/path_spec.rb +++ b/spec/bundler/install/gemfile/path_spec.rb @@ -439,7 +439,7 @@ RSpec.describe "bundle install with explicit source paths" do gem 'net-ssh', '1.0' G - bundle :check, :env => { "DEBUG" => 1 } + bundle :check, :env => { "DEBUG" => "1" } expect(out).to match(/using resolution from the lockfile/) expect(the_bundle).to include_gems "rack-obama 1.0", "net-ssh 1.0" end @@ -459,7 +459,7 @@ RSpec.describe "bundle install with explicit source paths" do gem 'net-ssh', :path => "#{lib_path("omg")}" G - bundle :check, :env => { "DEBUG" => 1 } + bundle :check, :env => { "DEBUG" => "1" } expect(out).to match(/using resolution from the lockfile/) expect(the_bundle).to include_gems "rack-obama 1.0", "net-ssh 1.0" end @@ -654,7 +654,7 @@ RSpec.describe "bundle install with explicit source paths" do File.open(lib_path("private_lib/Gemfile"), "w") {|f| f.puts gemfile } Dir.chdir(lib_path("private_lib")) do - bundle :install, :env => { "DEBUG" => 1 }, :artifice => "endpoint" + bundle :install, :env => { "DEBUG" => "1" }, :artifice => "endpoint" expect(out).to match(%r{^HTTP GET http://localgemserver\.test/api/v1/dependencies\?gems=rack$}) expect(out).not_to match(/^HTTP GET.*private_lib/) expect(the_bundle).to include_gems "private_lib 2.2" diff --git a/spec/bundler/install/gems/compact_index_spec.rb b/spec/bundler/install/gems/compact_index_spec.rb index 2c145ce643..a294b83d1c 100644 --- a/spec/bundler/install/gems/compact_index_spec.rb +++ b/spec/bundler/install/gems/compact_index_spec.rb @@ -51,7 +51,7 @@ RSpec.describe "compact index api" do build_gem "Rack", "0.1" end - install_gemfile! <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4 } + install_gemfile! <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } source "#{source_uri}" gem "rack", "1.0" gem "Rack", "0.1" diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb index 26ff40f7aa..52511ff67f 100644 --- a/spec/bundler/install/gems/resolving_spec.rb +++ b/spec/bundler/install/gems/resolving_spec.rb @@ -22,7 +22,7 @@ RSpec.describe "bundle install with install-time dependencies" do build_repo2 path = "#{gem_repo2}/#{Gem::MARSHAL_SPEC_DIR}/actionpack-2.3.2.gemspec.rz" - spec = Marshal.load(Bundler.rubygems.inflate(File.read(path))) + spec = Marshal.load(Bundler.rubygems.inflate(File.binread(path))) spec.dependencies.each do |d| d.instance_variable_set(:@type, :fail) end @@ -108,7 +108,7 @@ RSpec.describe "bundle install with install-time dependencies" do end end - install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2 } + install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } ruby "#{RUBY_VERSION}" source "http://localgemserver.test/" gem 'rack' @@ -127,7 +127,7 @@ RSpec.describe "bundle install with install-time dependencies" do build_gem "foo1", "1.0" end - install_gemfile <<-G, :artifice => "compact_index_rate_limited", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4 } + install_gemfile <<-G, :artifice => "compact_index_rate_limited", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } ruby "#{RUBY_VERSION}" source "http://localgemserver.test/" gem 'rack' @@ -153,7 +153,7 @@ RSpec.describe "bundle install with install-time dependencies" do 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 } + install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } source "http://localgemserver.test/" ruby #{ruby_requirement} gem 'require_ruby' diff --git a/spec/bundler/install/gems/sudo_spec.rb b/spec/bundler/install/gems/sudo_spec.rb index fcafe4a907..170ffaca03 100644 --- a/spec/bundler/install/gems/sudo_spec.rb +++ b/spec/bundler/install/gems/sudo_spec.rb @@ -172,7 +172,7 @@ RSpec.describe "when using sudo", :sudo => true do 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 } + bundle :install, :sudo => :preserve_env, :env => { "BUNDLE_SILENCE_ROOT_WARNING" => "true" } expect(err).to_not include(warning) end end diff --git a/spec/bundler/install/git_spec.rb b/spec/bundler/install/git_spec.rb index c16285241f..cc8bf70b03 100644 --- a/spec/bundler/install/git_spec.rb +++ b/spec/bundler/install/git_spec.rb @@ -61,5 +61,25 @@ RSpec.describe "bundle install" do expect(out).to include("Bundle complete!") end + + it "allows multiple gems from the same git source" do + build_repo2 do + build_lib "foo", "1.0", :path => lib_path("gems/foo") + build_lib "zebra", "2.0", :path => lib_path("gems/zebra") + build_git "gems", :path => lib_path("gems"), :gemspec => false + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "foo", :git => "#{lib_path("gems")}", :glob => "foo/*.gemspec" + gem "zebra", :git => "#{lib_path("gems")}", :glob => "zebra/*.gemspec" + G + + bundle "info foo" + expect(out).to include("* foo (1.0 #{revision_for(lib_path("gems"))[0..6]})") + + bundle "info zebra" + expect(out).to include("* zebra (2.0 #{revision_for(lib_path("gems"))[0..6]})") + end end end diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb index f743bccb92..df2fdd263a 100644 --- a/spec/bundler/other/major_deprecation_spec.rb +++ b/spec/bundler/other/major_deprecation_spec.rb @@ -127,7 +127,7 @@ RSpec.describe "major deprecations" do bundle! "config" end - it "warns", :bundler => "2" do + it "warns", :bundler => "3" do expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config list` instead.") end @@ -139,7 +139,7 @@ RSpec.describe "major deprecations" do bundle! "config waka" end - it "warns", :bundler => "2" do + it "warns", :bundler => "3" do expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config get waka` instead.") end @@ -151,7 +151,7 @@ RSpec.describe "major deprecations" do bundle! "config waka wakapun" end - it "warns", :bundler => "2" do + it "warns", :bundler => "3" do expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set waka wakapun` instead.") end @@ -163,7 +163,7 @@ RSpec.describe "major deprecations" do bundle! "config --local waka wakapun" end - it "warns", :bundler => "2" do + it "warns", :bundler => "3" do expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set --local waka wakapun` instead.") end @@ -175,7 +175,7 @@ RSpec.describe "major deprecations" do bundle! "config --global waka wakapun" end - it "warns", :bundler => "2" do + it "warns", :bundler => "3" do expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set --global waka wakapun` instead.") end @@ -187,7 +187,7 @@ RSpec.describe "major deprecations" do bundle! "config --delete waka" end - it "warns", :bundler => "2" do + it "warns", :bundler => "3" do expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset waka` instead.") end @@ -199,7 +199,7 @@ RSpec.describe "major deprecations" do bundle! "config --delete --local waka" end - it "warns", :bundler => "2" do + it "warns", :bundler => "3" do expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset --local waka` instead.") end @@ -211,7 +211,7 @@ RSpec.describe "major deprecations" do bundle! "config --delete --global waka" end - it "warns", :bundler => "2" do + it "warns", :bundler => "3" do expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset --global waka` instead.") end @@ -227,7 +227,7 @@ RSpec.describe "major deprecations" do G end - it "warns when no options are given", :bundler => "2" do + it "warns when no options are given", :bundler => "3" do bundle! "update" expect(deprecations).to include("Pass --all to `bundle update` to update everything") end diff --git a/spec/bundler/realworld/edgecases_spec.rb b/spec/bundler/realworld/edgecases_spec.rb index 53d9f9a026..a91e6a359e 100644 --- a/spec/bundler/realworld/edgecases_spec.rb +++ b/spec/bundler/realworld/edgecases_spec.rb @@ -8,7 +8,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do require "#{lib_dir}/bundler/source/rubygems/remote" require "#{lib_dir}/bundler/fetcher" rubygem = Bundler.ui.silence do - source = Bundler::Source::Rubygems::Remote.new(URI("https://rubygems.org")) + source = Bundler::Source::Rubygems::Remote.new(Bundler::URI("https://rubygems.org")) fetcher = Bundler::Fetcher.new(source) index = fetcher.specs([#{name.dump}], nil) index.search(Gem::Dependency.new(#{name.dump}, #{requirement.dump})).last diff --git a/spec/bundler/rubygems/rubygems.rb b/spec/bundler/rubygems/rubygems.rb deleted file mode 100644 index 6fa63013bf..0000000000 --- a/spec/bundler/rubygems/rubygems.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -require_relative "../support/rubygems_version_manager" - -RubygemsVersionManager.new(ENV["RGV"]).switch - -$:.delete("#{Spec::Path.spec_dir}/rubygems") - -require "rubygems" diff --git a/spec/bundler/runtime/gem_tasks_spec.rb b/spec/bundler/runtime/gem_tasks_spec.rb index 4760b6a749..4b92de76bb 100644 --- a/spec/bundler/runtime/gem_tasks_spec.rb +++ b/spec/bundler/runtime/gem_tasks_spec.rb @@ -6,15 +6,25 @@ RSpec.describe "require 'bundler/gem_tasks'" do f.write <<-GEMSPEC Gem::Specification.new do |s| s.name = "foo" + s.version = "1.0" + s.summary = "dummy" + s.author = "Perry Mason" end GEMSPEC end + bundled_app("Rakefile").open("w") do |f| f.write <<-RAKEFILE $:.unshift("#{lib_dir}") require "bundler/gem_tasks" RAKEFILE end + + install_gemfile! <<-G + source "#{file_uri_for(gem_repo1)}" + + gem "rake" + G end it "includes the relevant tasks" do @@ -22,7 +32,7 @@ RSpec.describe "require 'bundler/gem_tasks'" do sys_exec "#{rake} -T", "RUBYOPT" => "-I#{lib_dir}" end - expect(err).to eq("") + expect(err).to be_empty expected_tasks = [ "rake build", "rake clean", @@ -35,6 +45,18 @@ RSpec.describe "require 'bundler/gem_tasks'" do expect(exitstatus).to eq(0) if exitstatus end + it "defines a working `rake install` task" do + with_gem_path_as(Spec::Path.base_system_gems.to_s) do + sys_exec "#{rake} install", "RUBYOPT" => "-I#{lib_dir}" + end + + expect(err).to be_empty + + bundle! "exec rake install" + + expect(err).to be_empty + end + it "adds 'pkg' to rake/clean's CLOBBER" do with_gem_path_as(Spec::Path.base_system_gems.to_s) do sys_exec! %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect') diff --git a/spec/bundler/runtime/inline_spec.rb b/spec/bundler/runtime/inline_spec.rb index 06be2ef83d..94d8b086a2 100644 --- a/spec/bundler/runtime/inline_spec.rb +++ b/spec/bundler/runtime/inline_spec.rb @@ -5,7 +5,7 @@ RSpec.describe "bundler/inline#gemfile" do requires = ["#{lib_dir}/bundler/inline"] requires.unshift "#{spec_dir}/support/artifice/" + options.delete(:artifice) if options.key?(:artifice) requires = requires.map {|r| "require '#{r}'" }.join("\n") - @out = ruby("#{requires}\n\n" + code, options) + ruby("#{requires}\n\n" + code, options) end before :each do @@ -88,9 +88,8 @@ RSpec.describe "bundler/inline#gemfile" do RUBY expect(out).to include("Installing activesupport") - err.gsub! %r{(.*lib/sinatra/base\.rb:\d+: warning: constant ::Fixnum is deprecated$)}, "" err_lines = err.split("\n") - err_lines.reject!{|line| line =~ /\.rb:\d+: warning: / } + err_lines.reject!{|line| line =~ /\.rb:\d+: warning: / } unless RUBY_VERSION < "2.7" expect(err_lines).to be_empty expect(exitstatus).to be_zero if exitstatus end @@ -317,4 +316,21 @@ RSpec.describe "bundler/inline#gemfile" do expect(err).to be_empty end + + it "preserves previous BUNDLE_GEMFILE value" do + ENV["BUNDLE_GEMFILE"] = "" + script <<-RUBY + gemfile do + source "#{file_uri_for(gem_repo1)}" + gem "rack" + end + + puts "BUNDLE_GEMFILE is empty" if ENV["BUNDLE_GEMFILE"].empty? + system("#{Gem.ruby} -w -e '42'") # this should see original value of BUNDLE_GEMFILE + exit $?.exitstatus + RUBY + + expect(last_command).to be_success + expect(out).to include("BUNDLE_GEMFILE is empty") + end end diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index 4a754945b7..53300af618 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -130,7 +130,7 @@ RSpec.describe "Bundler.setup" do load_path = out.split("\n") rack_load_order = load_path.index {|path| path.include?("rack") } - expect(err).to eq("") + expect(err).to be_empty expect(load_path).to include(a_string_ending_with("dash_i_dir"), "rubylib_dir") expect(rack_load_order).to be > 0 end @@ -845,6 +845,12 @@ end end describe "when a vendored gem specification uses the :path option" do + let(:filesystem_root) do + current = Pathname.new(Dir.pwd) + current = current.parent until current == current.parent + current + end + it "should resolve paths relative to the Gemfile" do path = bundled_app(File.join("vendor", "foo")) build_lib "foo", :path => path @@ -858,7 +864,7 @@ end G Dir.chdir(bundled_app.parent) do - run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile") } + run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile").to_s } require 'foo' R end @@ -866,7 +872,7 @@ end end it "should make sure the Bundler.root is really included in the path relative to the Gemfile" do - relative_path = File.join("vendor", Dir.pwd[1..-1], "foo") + relative_path = File.join("vendor", Dir.pwd.gsub(/^#{filesystem_root}/, "")) absolute_path = bundled_app(relative_path) FileUtils.mkdir_p(absolute_path) build_lib "foo", :path => absolute_path @@ -882,7 +888,7 @@ end bundle :install Dir.chdir(bundled_app.parent) do - run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile") } + run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile").to_s } require 'foo' R end @@ -1027,6 +1033,8 @@ end ruby <<-RUBY require '#{lib_dir}/bundler' + bundler_module = class << Bundler; self; end + bundler_module.send(:remove_method, :require) def Bundler.require(path) raise "LOSE" end @@ -1034,7 +1042,7 @@ end RUBY expect(err).to be_empty - expect(out).to eq("") + expect(out).to be_empty end end @@ -1090,8 +1098,8 @@ end it "does not change the lock or warn" do lockfile lock_with(Bundler::VERSION.succ) ruby "require '#{lib_dir}/bundler/setup'" - expect(out).to eq("") - expect(err).to eq("") + expect(out).to be_empty + expect(err).to be_empty lockfile_should_be lock_with(Bundler::VERSION.succ) end end @@ -1154,8 +1162,8 @@ end let(:ruby_version) { "5.5.5" } it "does not change the lock or warn" do expect { ruby! "require '#{lib_dir}/bundler/setup'" }.not_to change { lockfile } - expect(out).to eq("") - expect(err).to eq("") + expect(out).to be_empty + expect(err).to be_empty end end @@ -1195,7 +1203,7 @@ end describe "default gem activation" do let(:exemptions) do if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7") - [] + %w[delegate did_you_mean] else %w[io-console openssl] end << "bundler" @@ -1204,17 +1212,15 @@ end let(:activation_warning_hack) { strip_whitespace(<<-RUBY) } require #{spec_dir.join("support/hax").to_s.dump} - if Gem::Specification.instance_methods.map(&:to_sym).include?(:activate) - Gem::Specification.send(:alias_method, :bundler_spec_activate, :activate) - Gem::Specification.send(:define_method, :activate) do - unless #{exemptions.inspect}.include?(name) - warn '-' * 80 - warn "activating \#{full_name}" - warn *caller - warn '*' * 80 - end - bundler_spec_activate + Gem::Specification.send(:alias_method, :bundler_spec_activate, :activate) + Gem::Specification.send(:define_method, :activate) do + unless #{exemptions.inspect}.include?(name) + warn '-' * 80 + warn "activating \#{full_name}" + warn(*caller) + warn '*' * 80 end + bundler_spec_activate end RUBY @@ -1238,14 +1244,14 @@ end it "activates no gems with -rbundler/setup" do install_gemfile! "" - ruby! code, :env => { :RUBYOPT => activation_warning_hack_rubyopt + " -r#{lib_dir}/bundler/setup" } + ruby! code, :env => { "RUBYOPT" => activation_warning_hack_rubyopt + " -r#{lib_dir}/bundler/setup" } expect(out).to eq("{}") end it "activates no gems with bundle exec" do install_gemfile! "" create_file("script.rb", code) - bundle! "exec ruby ./script.rb", :env => { :RUBYOPT => activation_warning_hack_rubyopt } + bundle! "exec ruby ./script.rb", :env => { "RUBYOPT" => activation_warning_hack_rubyopt } expect(out).to eq("{}") end @@ -1253,54 +1259,40 @@ end install_gemfile! "" create_file("script.rb", "#!/usr/bin/env ruby\n\n#{code}") FileUtils.chmod(0o777, bundled_app("script.rb")) - bundle! "exec ./script.rb", :artifice => nil, :env => { :RUBYOPT => activation_warning_hack_rubyopt } + bundle! "exec ./script.rb", :artifice => nil, :env => { "RUBYOPT" => activation_warning_hack_rubyopt } expect(out).to eq("{}") end - let(:default_gems) do - ruby!(<<-RUBY).split("\n") - if Gem::Specification.is_a?(Enumerable) - puts Gem::Specification.select(&:default_gem?).map(&:name) - end - RUBY - end + Gem::Specification.select(&:default_gem?).map(&:name).each do |g| + it "activates newer versions of #{g}" do + skip if exemptions.include?(g) - it "activates newer versions of default gems" do - build_repo4 do - default_gems.each do |g| + build_repo4 do build_gem g, "999999" end - end - default_gems.reject! {|g| exemptions.include?(g) } + install_gemfile! <<-G + source "#{file_uri_for(gem_repo4)}" + gem "#{g}", "999999" + G - install_gemfile! <<-G - source "#{file_uri_for(gem_repo4)}" - #{default_gems}.each do |g| - gem g, "999999" - end - G + expect(the_bundle).to include_gem("#{g} 999999", :env => { "RUBYOPT" => activation_warning_hack_rubyopt }) + end - expect(the_bundle).to include_gems(*default_gems.map {|g| "#{g} 999999" }) - end + it "activates older versions of #{g}" do + skip if exemptions.include?(g) - it "activates older versions of default gems" do - build_repo4 do - default_gems.each do |g| + build_repo4 do build_gem g, "0.0.0.a" end - end - default_gems.reject! {|g| exemptions.include?(g) } + install_gemfile! <<-G + source "#{file_uri_for(gem_repo4)}" + gem "#{g}", "0.0.0.a" + G - install_gemfile! <<-G - source "#{file_uri_for(gem_repo4)}" - #{default_gems}.each do |g| - gem g, "0.0.0.a" - end - G - - expect(the_bundle).to include_gems(*default_gems.map {|g| "#{g} 0.0.0.a" }) + expect(the_bundle).to include_gem("#{g} 0.0.0.a", :env => { "RUBYOPT" => activation_warning_hack_rubyopt }) + end end end end diff --git a/spec/bundler/spec_helper.rb b/spec/bundler/spec_helper.rb index 9702ab71f5..0a49b46aaa 100644 --- a/spec/bundler/spec_helper.rb +++ b/spec/bundler/spec_helper.rb @@ -7,7 +7,7 @@ $:.unshift Spec::Path.lib_dir.to_s require "bundler/psyched_yaml" require "bundler/vendored_fileutils" -require "uri" +require "bundler/vendored_uri" require "digest" if File.expand_path(__FILE__) =~ %r{([^\w/\.:\-])} @@ -82,7 +82,7 @@ RSpec.configure do |config| config.before :suite do require_relative "support/rubygems_ext" Spec::Rubygems.setup - ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -I#{Spec::Path.spec_dir}/rubygems -r#{Spec::Path.spec_dir}/support/hax.rb" + ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{Spec::Path.spec_dir}/support/hax.rb" ENV["BUNDLE_SPEC_RUN"] = "true" ENV["BUNDLE_USER_CONFIG"] = ENV["BUNDLE_USER_CACHE"] = ENV["BUNDLE_USER_PLUGIN"] = nil ENV["GEMRC"] = nil diff --git a/spec/bundler/support/artifice/compact_index.rb b/spec/bundler/support/artifice/compact_index.rb index 89362c4dbc..72abf26224 100644 --- a/spec/bundler/support/artifice/compact_index.rb +++ b/spec/bundler/support/artifice/compact_index.rb @@ -10,7 +10,7 @@ class CompactIndexAPI < Endpoint def load_spec(name, version, platform, gem_repo) full_name = "#{name}-#{version}" full_name += "-#{platform}" if platform != "ruby" - Marshal.load(Bundler.rubygems.inflate(File.open(gem_repo.join("quick/Marshal.4.8/#{full_name}.gemspec.rz")).read)) + Marshal.load(Bundler.rubygems.inflate(File.binread(gem_repo.join("quick/Marshal.4.8/#{full_name}.gemspec.rz")))) end def etag_response diff --git a/spec/bundler/support/artifice/compact_index_api_missing.rb b/spec/bundler/support/artifice/compact_index_api_missing.rb index fdd342bc08..6514fde01e 100644 --- a/spec/bundler/support/artifice/compact_index_api_missing.rb +++ b/spec/bundler/support/artifice/compact_index_api_missing.rb @@ -10,7 +10,7 @@ class CompactIndexApiMissing < CompactIndexAPI if params[:id] == "rack-1.0.gemspec.rz" halt 404 else - File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}") + File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}") end end end diff --git a/spec/bundler/support/artifice/compact_index_extra_api_missing.rb b/spec/bundler/support/artifice/compact_index_extra_api_missing.rb index 6bd24ddbb4..b9d757c266 100644 --- a/spec/bundler/support/artifice/compact_index_extra_api_missing.rb +++ b/spec/bundler/support/artifice/compact_index_extra_api_missing.rb @@ -9,7 +9,7 @@ class CompactIndexExtraAPIMissing < CompactIndexExtraApi if params[:id] == "missing-1.0.gemspec.rz" halt 404 else - File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}") + File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}") end end end diff --git a/spec/bundler/support/artifice/compact_index_extra_missing.rb b/spec/bundler/support/artifice/compact_index_extra_missing.rb index 4758b785ac..ff1e47a1bb 100644 --- a/spec/bundler/support/artifice/compact_index_extra_missing.rb +++ b/spec/bundler/support/artifice/compact_index_extra_missing.rb @@ -9,7 +9,7 @@ class CompactIndexExtraMissing < CompactIndexExtra if params[:id] == "missing-1.0.gemspec.rz" halt 404 else - File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}") + File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}") end end end diff --git a/spec/bundler/support/artifice/endpoint.rb b/spec/bundler/support/artifice/endpoint.rb index bf26c56503..7bca681e70 100644 --- a/spec/bundler/support/artifice/endpoint.rb +++ b/spec/bundler/support/artifice/endpoint.rb @@ -68,7 +68,7 @@ class Endpoint < Sinatra::Base def load_spec(name, version, platform, gem_repo) full_name = "#{name}-#{version}" full_name += "-#{platform}" if platform != "ruby" - Marshal.load(Bundler.rubygems.inflate(File.open(gem_repo.join("quick/Marshal.4.8/#{full_name}.gemspec.rz")).read)) + Marshal.load(Bundler.rubygems.inflate(File.binread(gem_repo.join("quick/Marshal.4.8/#{full_name}.gemspec.rz")))) end end diff --git a/spec/bundler/support/artifice/endpoint_api_missing.rb b/spec/bundler/support/artifice/endpoint_api_missing.rb index 8dafde7362..755c42e836 100644 --- a/spec/bundler/support/artifice/endpoint_api_missing.rb +++ b/spec/bundler/support/artifice/endpoint_api_missing.rb @@ -10,7 +10,7 @@ class EndpointApiMissing < Endpoint if params[:id] == "rack-1.0.gemspec.rz" halt 404 else - File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}") + File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}") end end end diff --git a/spec/bundler/support/artifice/endpoint_extra_missing.rb b/spec/bundler/support/artifice/endpoint_extra_missing.rb index ee129025ff..5fd9238207 100644 --- a/spec/bundler/support/artifice/endpoint_extra_missing.rb +++ b/spec/bundler/support/artifice/endpoint_extra_missing.rb @@ -9,7 +9,7 @@ class EndpointExtraMissing < EndpointExtra if params[:id] == "missing-1.0.gemspec.rz" halt 404 else - File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}") + File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}") end end end diff --git a/spec/bundler/support/artifice/windows.rb b/spec/bundler/support/artifice/windows.rb index ce7455b86c..21170c81d9 100644 --- a/spec/bundler/support/artifice/windows.rb +++ b/spec/bundler/support/artifice/windows.rb @@ -27,7 +27,7 @@ class Windows < Sinatra::Base files.each do |file| get "/#{file}" do - File.read gem_repo.join(file) + File.binread gem_repo.join(file) end end diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb index 911f734d8b..7d1bd65185 100644 --- a/spec/bundler/support/helpers.rb +++ b/spec/bundler/support/helpers.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "open3" - require_relative "command_execution" require_relative "the_bundle" @@ -25,9 +23,7 @@ module Spec define_method("#{method}!") do |*args, &blk| send(method, *args, &blk).tap do unless last_command.success? - raise RuntimeError, - "Invoking #{method}!(#{args.map(&:inspect).join(", ")}) failed:\n#{last_command.stdboth}", - caller.drop_while {|bt| bt.start_with?(__FILE__) } + raise "Invoking #{method}!(#{args.map(&:inspect).join(", ")}) failed:\n#{last_command.stdboth}" end end end @@ -174,7 +170,7 @@ module Spec env = options.delete(:env) || {} ruby = ruby.gsub(/["`\$]/) {|m| "\\#{m}" } lib_option = options[:no_lib] ? "" : " -I#{lib_dir}" - sys_exec(%(#{Gem.ruby}#{lib_option} -e "#{ruby}"), env) + sys_exec(%(#{Gem.ruby}#{lib_option} -w -e "#{ruby}"), env) end bang :ruby @@ -209,8 +205,7 @@ module Spec def sys_exec(cmd, env = {}) command_execution = CommandExecution.new(cmd.to_s, Dir.pwd) - env = env.map {|k, v| [k.to_s, v.to_s] }.to_h # convert env keys and values to string - + require "open3" Open3.popen3(env, cmd.to_s) do |stdin, stdout, stderr, wait_thr| yield stdin, stdout, wait_thr if block_given? stdin.close diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb index 6f78490fe8..eea3161b15 100644 --- a/spec/bundler/support/path.rb +++ b/spec/bundler/support/path.rb @@ -22,7 +22,7 @@ module Spec end def gem_bin - @gem_bin ||= ruby_core? ? ENV["GEM_COMMAND"] : "#{Gem.ruby} -I#{spec_dir}/rubygems -S gem --backtrace" + @gem_bin ||= ruby_core? ? ENV["GEM_COMMAND"] : "#{Gem.ruby} -S gem --backtrace" end def spec_dir @@ -30,23 +30,20 @@ module Spec end def tracked_files - if root != `git rev-parse --show-toplevel` - skip 'not in git working directory' - end + skip "not in git working directory" unless git_root_dir? + @tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler man/bundler*` : `git ls-files -z` end def shipped_files - if root != `git rev-parse --show-toplevel` - skip 'not in git working directory' - end + skip "not in git working directory" unless git_root_dir? + @shipped_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb man/bundler* libexec/bundle*` : `git ls-files -z -- lib man exe CHANGELOG.md LICENSE.md README.md bundler.gemspec` end def lib_tracked_files - if root != `git rev-parse --show-toplevel` - skip 'not in git working directory' - end + skip "not in git working directory" unless git_root_dir? + @lib_tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib` end @@ -103,8 +100,6 @@ module Spec protocol = "file://" root = Gem.win_platform? ? "/" : "" - return protocol + "localhost" + root + path.to_s if RUBY_VERSION < "2.5" - protocol + root + path.to_s end @@ -182,5 +177,11 @@ module Spec end extend self + + private + + def git_root_dir? + root.to_s == `git rev-parse --show-toplevel`.chomp + end end end diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb index d237897b67..7e9e8328c5 100644 --- a/spec/bundler/support/rubygems_ext.rb +++ b/spec/bundler/support/rubygems_ext.rb @@ -5,13 +5,13 @@ require_relative "path" module Spec module Rubygems DEV_DEPS = { - "automatiek" => "~> 0.2.0", + "automatiek" => "~> 0.3.0", "parallel_tests" => "~> 2.29", "rake" => "~> 12.0", "ronn" => "~> 0.7.3", "rspec" => "~> 3.8", - "rubocop" => "= 0.74.0", - "rubocop-performance" => "= 1.4.0", + "rubocop" => "= 0.77.0", + "rubocop-performance" => "= 1.5.1", }.freeze DEPS = { @@ -39,7 +39,9 @@ module Spec end def gem_load(gem_name, bin_container) - require_relative "../rubygems/rubygems" + require_relative "rubygems_version_manager" + RubygemsVersionManager.new(ENV["RGV"]).switch + gem_load_and_activate(gem_name, bin_container) end @@ -65,7 +67,7 @@ module Spec FileUtils.mkdir_p(Path.base_system_gems) puts "installing gems for the tests to use..." install_gems(DEPS) - manifest_path.open("w") {|f| f << manifest.join } + manifest_path.open("wb") {|f| f << manifest.join } end FileUtils.mkdir_p(Path.home) diff --git a/spec/bundler/support/rubygems_version_manager.rb b/spec/bundler/support/rubygems_version_manager.rb index 356d391c08..854bce890d 100644 --- a/spec/bundler/support/rubygems_version_manager.rb +++ b/spec/bundler/support/rubygems_version_manager.rb @@ -8,27 +8,25 @@ class RubygemsVersionManager include Spec::Helpers include Spec::Path - def initialize(env_version) - @env_version = env_version + def initialize(source) + @source = source end def switch return if use_system? - unrequire_rubygems_if_needed - switch_local_copy_if_needed - prepare_environment + reexec_if_needed end private def use_system? - @env_version.nil? + @source.nil? end - def unrequire_rubygems_if_needed + def reexec_if_needed return unless rubygems_unrequire_needed? require "rbconfig" @@ -37,7 +35,8 @@ private ruby << RbConfig::CONFIG["EXEEXT"] cmd = [ruby, $0, *ARGV].compact - cmd[1, 0] = "--disable-gems" + + ENV["RUBYOPT"] = "-I#{local_copy_path.join("lib")} #{ENV["RUBYOPT"]}" exec(ENV, *cmd) end @@ -47,35 +46,28 @@ private Dir.chdir(local_copy_path) do sys_exec!("git remote update") - sys_exec!("git checkout #{target_tag_version} --quiet") + sys_exec!("git checkout #{target_tag} --quiet") end - end - def prepare_environment - $:.unshift File.expand_path("lib", local_copy_path) + ENV["RGV"] = local_copy_path.to_s end def rubygems_unrequire_needed? - defined?(Gem::VERSION) && Gem::VERSION != target_gem_version + !$LOADED_FEATURES.include?(local_copy_path.join("lib/rubygems.rb").to_s) end def local_copy_switch_needed? - !env_version_is_path? && target_gem_version != local_copy_version - end - - def target_gem_version - @target_gem_version ||= resolve_target_gem_version + !source_is_path? && target_tag != local_copy_tag end - def target_tag_version - @target_tag_version ||= resolve_target_tag_version + def target_tag + @target_tag ||= resolve_target_tag end - def local_copy_version - gemspec_contents = File.read(local_copy_path.join("lib/rubygems.rb")) - version_regexp = /VERSION = ["'](.*)["']/ - - version_regexp.match(gemspec_contents)[1] + def local_copy_tag + Dir.chdir(local_copy_path) do + sys_exec!("git rev-parse --abbrev-ref HEAD") + end end def local_copy_path @@ -83,7 +75,7 @@ private end def resolve_local_copy_path - return expanded_env_version if env_version_is_path? + return expanded_source if source_is_path? rubygems_path = root.join("tmp/rubygems") @@ -95,33 +87,17 @@ private rubygems_path end - def env_version_is_path? - expanded_env_version.directory? + def source_is_path? + expanded_source.directory? end - def expanded_env_version - @expanded_env_version ||= Pathname.new(@env_version).expand_path(root) + def expanded_source + @expanded_source ||= Pathname.new(@source).expand_path(root) end - def resolve_target_tag_version - return "v#{@env_version}" if @env_version.match(/^\d/) - - return "master" if @env_version == master_gem_version - - @env_version - end - - def resolve_target_gem_version - return local_copy_version if env_version_is_path? - - return @env_version[1..-1] if @env_version.match(/^v/) - - return master_gem_version if @env_version == "master" - - @env_version - end + def resolve_target_tag + return "v#{@source}" if @source.match(/^\d/) - def master_gem_version - "3.1.0.pre1" + @source end end |