summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-12-27 09:28:09 +0700
committerSamuel Giddins <segiddins@segiddins.me>2017-12-27 09:28:09 +0700
commit3f244c698d1db82d19e8cd660ae0c0f80960f8fe (patch)
tree858cd14e8771764875675c4548f3c42ff5c55a0d
parent2cc5221263cd5fe8d347a9d3de9aff9fed685742 (diff)
parent0034ef3416ca94d00839361dbeb0485b10a09c51 (diff)
downloadbundler-3f244c698d1db82d19e8cd660ae0c0f80960f8fe.tar.gz
Merge tag 'v1.16.1'
Version 1.16.1 # gpg: Signature made Fri Dec 22 01:46:37 2017 +07 # gpg: using ? key C3DA1D6CEFC720FA # gpg: Can't check signature: unknown pubkey algorithm # Conflicts: # lib/bundler/version.rb # spec/commands/exec_spec.rb # spec/realworld/double_check_spec.rb # spec/runtime/with_clean_env_spec.rb # spec/spec_helper.rb
-rw-r--r--CHANGELOG.md13
-rw-r--r--spec/bundler/definition_spec.rb12
-rw-r--r--spec/bundler/fetcher_spec.rb12
-rw-r--r--spec/commands/exec_spec.rb30
-rw-r--r--spec/commands/lock_spec.rb10
-rw-r--r--spec/commands/newgem_spec.rb4
-rw-r--r--spec/commands/pristine_spec.rb5
-rw-r--r--spec/install/gemfile/gemspec_spec.rb14
-rw-r--r--spec/install/gemfile/sources_spec.rb25
-rw-r--r--spec/install/gems/flex_spec.rb10
-rw-r--r--spec/install/gems/mirror_spec.rb12
-rw-r--r--spec/lock/lockfile_bundler_1_spec.rb132
-rw-r--r--spec/plugins/source/example_spec.rb12
-rw-r--r--spec/realworld/double_check_spec.rb2
-rw-r--r--spec/runtime/gem_tasks_spec.rb6
-rw-r--r--spec/runtime/require_spec.rb6
-rw-r--r--spec/runtime/setup_spec.rb12
-rw-r--r--spec/runtime/with_clean_env_spec.rb39
-rw-r--r--spec/spec_helper.rb19
-rw-r--r--spec/support/builders.rb2
-rw-r--r--spec/support/hax.rb6
-rw-r--r--spec/update/git_spec.rb6
22 files changed, 219 insertions, 170 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a47a411077..bbf9abe033 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,16 @@
+## 1.16.1 (2017-12-12)
+
+Bugfixes:
+
+ - avoid hanging on complex resolver errors ([#6114](https://github.com/bundler/bundler/issues/6114), @halfbyte)
+ - avoid an error when running `bundle update --group` ([#6156](https://github.com/bundler/bundler/issues/6156), @mattbrictson)
+ - ensure the resolver prefers non-pre-release gems when possible ([#6181](https://github.com/bundler/bundler/issues/6181), @greysteil)
+ - include bundler's gemspec in the built gem ([#6165](https://github.com/bundler/bundler/issues/6165), @dr-itz)
+ - ensure locally installed specs are not overriden by those in remote sources during dependency resolution ([#6072](https://github.com/bundler/bundler/issues/6072), @indirect)
+ - ensure custom gemfiles are respected in generated binstubs (@pftg)
+ - fail gracefully when loading a bundler-generated binstub when `bin/bundle` was not generated by bundler ([#6149](https://github.com/bundler/bundler/issues/6149), @hsbt)
+ - allow `bundle init` to be run even when a parent directory contains a gemfile ([#6205](https://github.com/bundler/bundler/issues/6205), @colby-swandale)
+
## 1.16.0 (2017-10-31)
Bugfixes:
diff --git a/spec/bundler/definition_spec.rb b/spec/bundler/definition_spec.rb
index 5abf0d9756..3ca0dc0f79 100644
--- a/spec/bundler/definition_spec.rb
+++ b/spec/bundler/definition_spec.rb
@@ -36,7 +36,7 @@ RSpec.describe Bundler::Definition do
build_lib "foo", "1.0", :path => lib_path("foo")
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "foo", :path => "#{lib_path("foo")}"
G
@@ -55,7 +55,7 @@ RSpec.describe Bundler::Definition do
rack (= 1.0)
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -115,7 +115,7 @@ RSpec.describe Bundler::Definition do
end
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "foo", :path => "#{lib_path("foo")}"
G
@@ -130,7 +130,7 @@ RSpec.describe Bundler::Definition do
rack (= 1.0)
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -184,7 +184,7 @@ RSpec.describe Bundler::Definition do
it "for a rubygems gem" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "foo"
G
@@ -193,7 +193,7 @@ RSpec.describe Bundler::Definition do
expect(out).to match(/using resolution from the lockfile/)
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
foo (1.0)
diff --git a/spec/bundler/fetcher_spec.rb b/spec/bundler/fetcher_spec.rb
index f9e52e09c0..184b9efa64 100644
--- a/spec/bundler/fetcher_spec.rb
+++ b/spec/bundler/fetcher_spec.rb
@@ -95,11 +95,15 @@ RSpec.describe Bundler::Fetcher do
context "when bunder ssl ssl configuration is set" do
before do
+ cert = File.join(Spec::Path.tmpdir, "cert")
+ File.open(cert, "w") {|f| f.write "PEM" }
allow(Bundler.settings).to receive(:[]).and_return(nil)
- allow(Bundler.settings).to receive(:[]).with(:ssl_client_cert).and_return("/cert")
- expect(File).to receive(:read).with("/cert").and_return("")
- expect(OpenSSL::X509::Certificate).to receive(:new).and_return("cert")
- expect(OpenSSL::PKey::RSA).to receive(:new).and_return("key")
+ allow(Bundler.settings).to receive(:[]).with(:ssl_client_cert).and_return(cert)
+ expect(OpenSSL::X509::Certificate).to receive(:new).with("PEM").and_return("cert")
+ expect(OpenSSL::PKey::RSA).to receive(:new).with("PEM").and_return("key")
+ end
+ after do
+ FileUtils.rm File.join(Spec::Path.tmpdir, "cert")
end
it "use bundler configuration" do
expect(fetcher.send(:connection).cert).to eq("cert")
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index ae31487937..af88f3f043 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe "bundle exec" do
gem "rack"
G
- bundle "exec 'cd #{tmp("gems")} && rackup'"
+ bundle "exec 'cd #{tmp("gems")} && rackup'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to include("1.0.0")
end
@@ -42,7 +42,7 @@ RSpec.describe "bundle exec" do
it "works when exec'ing to ruby" do
install_gemfile 'gem "rack"'
- bundle "exec ruby -e 'puts %{hi}'"
+ bundle "exec ruby -e 'puts %{hi}'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to eq("hi")
end
@@ -76,7 +76,9 @@ RSpec.describe "bundle exec" do
G
install_gemfile ""
- sys_exec("#{Gem.ruby} #{command.path}")
+ with_env_vars "RUBYOPT" => "-r#{spec_dir.join("support/hax")}" do
+ sys_exec "#{Gem.ruby} #{command.path}"
+ end
if Bundler.current_ruby.ruby_2?
expect(out).to eq("")
@@ -237,7 +239,7 @@ RSpec.describe "bundle exec" do
G
[true, false].each do |l|
bundle! "config disable_exec_load #{l}"
- bundle "exec rackup"
+ bundle "exec rackup", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(last_command.stderr).to include "rack is not part of the bundle. Add it to your Gemfile."
end
end
@@ -339,14 +341,14 @@ RSpec.describe "bundle exec" do
end
it "works when unlocked" do
- bundle "exec 'cd #{tmp("gems")} && rackup'"
+ bundle "exec 'cd #{tmp("gems")} && rackup'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to eq("1.0.0")
expect(out).to include("1.0.0")
end
it "works when locked" do
expect(the_bundle).to be_locked
- bundle "exec 'cd #{tmp("gems")} && rackup'"
+ bundle "exec 'cd #{tmp("gems")} && rackup'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to include("1.0.0")
end
end
@@ -472,7 +474,7 @@ RSpec.describe "bundle exec" do
Bundler.rubygems.extend(Monkey)
G
bundle "install --deployment"
- bundle "exec ruby -e '`#{bindir.join("bundler")} -v`; puts $?.success?'"
+ bundle "exec ruby -e '`#{bindir.join("bundler")} -v`; puts $?.success?'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to match("true")
end
end
@@ -512,7 +514,7 @@ RSpec.describe "bundle exec" do
let(:expected) { [exec, args, rack, process].join("\n") }
let(:expected_err) { "" }
- subject { bundle "exec #{path} arg1 arg2" }
+ subject { bundle "exec #{path} arg1 arg2", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" } }
shared_examples_for "it runs" do
it "like a normally executed executable" do
@@ -550,6 +552,7 @@ RSpec.describe "bundle exec" do
ex << "raise SignalException, 'SIGTERM'\n"
ex
end
+ let(:expected_err) { ENV["TRAVIS"] ? "Terminated" : "" }
let(:exit_code) do
# signal mask 128 + plus signal 15 -> TERM
# this is specified by C99
@@ -778,10 +781,13 @@ __FILE__: #{path.to_s.inspect}
file.chmod(0o777)
aggregate_failures do
- expect(bundle!("exec #{file}", :system_bundler => true, :artifice => nil)).to eq(expected)
- expect(bundle!("exec bundle exec #{file}", :system_bundler => true, :artifice => nil)).to eq(expected)
- expect(bundle!("exec ruby #{file}", :system_bundler => true, :artifice => nil)).to eq(expected)
- expect(run!(file.read, :no_lib => true, :artifice => nil)).to eq(expected)
+ expect(bundle!("exec #{file}", :artifice => nil)).to eq(expected)
+ expect(bundle!("exec bundle exec #{file}", :artifice => nil)).to eq(expected)
+ expect(bundle!("exec ruby #{file}", :artifice => nil)).to eq(expected)
+ # Ignore expectaion for default bundler gem conflict.
+ unless ENV["BUNDLER_SPEC_SUB_VERSION"]
+ expect(run!(file.read, :no_lib => true, :artifice => nil)).to eq(expected)
+ end
end
# sanity check that we get the newer, custom version without bundler
diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb
index 8edbb95b0f..b08cc865b1 100644
--- a/spec/commands/lock_spec.rb
+++ b/spec/commands/lock_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe "bundle lock" do
before :each do
gemfile <<-G
- source "file://#{repo}"
+ source "file://localhost#{repo}"
gem "rails"
gem "with_license"
gem "foo"
@@ -21,7 +21,7 @@ RSpec.describe "bundle lock" do
@lockfile = strip_lockfile <<-L
GEM
- remote: file:#{repo}/
+ remote: file://localhost#{repo}/
specs:
actionmailer (2.3.2)
activesupport (= 2.3.2)
@@ -228,7 +228,7 @@ RSpec.describe "bundle lock" do
end
gemfile <<-G
- source "file:#{gem_repo4}"
+ source "file://localhost#{gem_repo4}"
gem "mixlib-shellout"
gem "gssapi"
@@ -238,7 +238,7 @@ RSpec.describe "bundle lock" do
expect(the_bundle.lockfile).to read_as(strip_whitespace(<<-G))
GEM
- remote: file:#{gem_repo4}/
+ remote: file://localhost#{gem_repo4}/
specs:
ffi (1.9.14-x86-mingw32)
gssapi (1.2.0)
@@ -263,7 +263,7 @@ RSpec.describe "bundle lock" do
expect(the_bundle.lockfile).to read_as(strip_whitespace(<<-G))
GEM
- remote: file:#{gem_repo4}/
+ remote: file://localhost#{gem_repo4}/
specs:
ffi (1.9.14)
ffi (1.9.14-x86-mingw32)
diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb
index 494599abf1..1a3e8236b6 100644
--- a/spec/commands/newgem_spec.rb
+++ b/spec/commands/newgem_spec.rb
@@ -191,7 +191,7 @@ RSpec.describe "bundle gem" do
it "generates a valid gemspec" do
in_app_root
- bundle "gem newgem --bin"
+ bundle! "gem newgem --bin"
process_file(bundled_app("newgem", "newgem.gemspec")) do |line|
# Simulate replacing TODOs with real values
@@ -211,7 +211,7 @@ RSpec.describe "bundle gem" do
end
Dir.chdir(bundled_app("newgem")) do
- system_gems ["rake-10.0.2"], :path => :bundle_path
+ system_gems ["rake-10.0.2", :bundler], :path => :bundle_path
bundle! "exec rake build"
end
diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb
index 108606e8aa..4642a8167d 100644
--- a/spec/commands/pristine_spec.rb
+++ b/spec/commands/pristine_spec.rb
@@ -41,11 +41,14 @@ RSpec.describe "bundle pristine" do
end
it "does not delete the bundler gem" do
+ ENV["BUNDLER_SPEC_KEEP_DEFAULT_BUNDLER_GEM"] = "true"
system_gems :bundler
bundle! "install"
bundle! "pristine", :system_bundler => true
bundle! "-v", :system_bundler => true
- expect(out).to end_with(Bundler::VERSION)
+ # An old rubygems couldn't handle a correct version of vendoered bundler.
+ bundler_version = Gem::VERSION < "2.1" ? "1.16.0" : Bundler::VERSION
+ expect(out).to end_with(bundler_version)
end
end
diff --git a/spec/install/gemfile/gemspec_spec.rb b/spec/install/gemfile/gemspec_spec.rb
index 1dc016ed23..86cd2d8f3f 100644
--- a/spec/install/gemfile/gemspec_spec.rb
+++ b/spec/install/gemfile/gemspec_spec.rb
@@ -426,7 +426,7 @@ RSpec.describe "bundle install from an existing gemspec" do
%w[ruby jruby].each do |platform|
simulate_platform(platform) do
install_gemfile <<-G
- source "file://#{gem_repo2}"
+ source "file://localhost#{gem_repo2}"
gemspec
G
end
@@ -450,7 +450,7 @@ RSpec.describe "bundle install from an existing gemspec" do
platform_specific
GEM
- remote: file:#{gem_repo2}/
+ remote: file://localhost#{gem_repo2}/
specs:
platform_specific (1.0)
platform_specific (1.0-java)
@@ -480,7 +480,7 @@ RSpec.describe "bundle install from an existing gemspec" do
foo (1.0)
GEM
- remote: file:#{gem_repo2}/
+ remote: file://localhost#{gem_repo2}/
specs:
platform_specific (1.0)
platform_specific (1.0-java)
@@ -512,7 +512,7 @@ RSpec.describe "bundle install from an existing gemspec" do
foo (1.0)
GEM
- remote: file:#{gem_repo2}/
+ remote: file://localhost#{gem_repo2}/
specs:
indirect_platform_specific (1.0)
platform_specific
@@ -545,7 +545,7 @@ RSpec.describe "bundle install from an existing gemspec" do
expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
expect(lockfile).to eq strip_whitespace(<<-L)
GEM
- remote: file:#{gem_repo2}/
+ remote: file://localhost#{gem_repo2}/
specs:
platform_specific (1.0)
platform_specific (1.0-java)
@@ -576,7 +576,7 @@ RSpec.describe "bundle install from an existing gemspec" do
expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
expect(lockfile).to eq strip_whitespace(<<-L)
GEM
- remote: file:#{gem_repo2}/
+ remote: file://localhost#{gem_repo2}/
specs:
platform_specific (1.0)
platform_specific (1.0-java)
@@ -608,7 +608,7 @@ RSpec.describe "bundle install from an existing gemspec" do
expect(the_bundle).to include_gems "foo 1.0", "indirect_platform_specific 1.0", "platform_specific 1.0 RUBY"
expect(lockfile).to eq strip_whitespace(<<-L)
GEM
- remote: file:#{gem_repo2}/
+ remote: file://localhost#{gem_repo2}/
specs:
indirect_platform_specific (1.0)
platform_specific
diff --git a/spec/install/gemfile/sources_spec.rb b/spec/install/gemfile/sources_spec.rb
index 8d69a663de..bac0a113f9 100644
--- a/spec/install/gemfile/sources_spec.rb
+++ b/spec/install/gemfile/sources_spec.rb
@@ -20,8 +20,8 @@ RSpec.describe "bundle install with gems on multiple sources" do
before do
gemfile <<-G
- source "file://#{gem_repo3}"
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo3}"
+ source "file://localhost#{gem_repo1}"
gem "rack-obama"
gem "rack"
G
@@ -33,7 +33,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(out).to include("Installed from: file:#{gem_repo1}")
+ expect(out).to include("Installed from: file://localhost#{gem_repo1}")
expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1")
end
@@ -50,8 +50,8 @@ RSpec.describe "bundle install with gems on multiple sources" do
before do
gemfile <<-G
- source "file://#{gem_repo3}"
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo3}"
+ source "file://localhost#{gem_repo1}"
gem "rack-obama"
gem "rack", "1.0.0" # force it to install the working version in repo1
G
@@ -63,7 +63,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(out).to include("Installed from: file:#{gem_repo1}")
+ expect(out).to include("Installed from: file://localhost#{gem_repo1}")
expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1")
end
end
@@ -240,9 +240,9 @@ RSpec.describe "bundle install with gems on multiple sources" do
context "and in yet another source" do
before do
gemfile <<-G
- source "file://#{gem_repo1}"
- source "file://#{gem_repo2}"
- source "file://#{gem_repo3}" do
+ source "file://localhost#{gem_repo1}"
+ source "file://localhost#{gem_repo2}"
+ source "file://localhost#{gem_repo3}" do
gem "depends_on_rack"
end
G
@@ -253,7 +253,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
bundle :install
expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(out).to include("Installed from: file:#{gem_repo2}")
+ expect(out).to include("Installed from: file://localhost#{gem_repo2}")
expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
end
end
@@ -435,12 +435,11 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
it "does not unlock the non-path gem after install" do
- bundle :install
+ bundle! :install
- bundle %(exec ruby -e 'puts "OK"')
+ bundle! %(exec ruby -e 'puts "OK"'), :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to include("OK")
- expect(exitstatus).to eq(0) if exitstatus
end
end
end
diff --git a/spec/install/gems/flex_spec.rb b/spec/install/gems/flex_spec.rb
index f6af806154..f8b40f8e4e 100644
--- a/spec/install/gems/flex_spec.rb
+++ b/spec/install/gems/flex_spec.rb
@@ -247,19 +247,19 @@ RSpec.describe "bundle flex_install" do
it "updates the lockfile", :bundler => "< 2" do
build_repo2
install_gemfile! <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
G
install_gemfile! <<-G
- source "file://#{gem_repo1}"
- source "file://#{gem_repo2}"
+ source "file://localhost#{gem_repo1}"
+ source "file://localhost#{gem_repo2}"
gem "rack"
G
lockfile_should_be <<-L
GEM
- remote: file:#{gem_repo1}/
- remote: file:#{gem_repo2}/
+ remote: file://localhost#{gem_repo1}/
+ remote: file://localhost#{gem_repo2}/
specs:
rack (1.0.0)
diff --git a/spec/install/gems/mirror_spec.rb b/spec/install/gems/mirror_spec.rb
index a8516a28c3..89302615f1 100644
--- a/spec/install/gems/mirror_spec.rb
+++ b/spec/install/gems/mirror_spec.rb
@@ -4,7 +4,7 @@ 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://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
G
@@ -13,7 +13,7 @@ RSpec.describe "bundle install with a mirror configured" do
it "installs from the normal location" do
bundle :install
- expect(out).to include("Fetching source index from file:#{gem_repo1}")
+ expect(out).to include("Fetching source index from file://localhost#{gem_repo1}")
expect(the_bundle).to include_gems "rack 1.0"
end
end
@@ -22,17 +22,17 @@ RSpec.describe "bundle install with a mirror configured" do
before :each do
gemfile <<-G
# This source is bogus and doesn't have the gem we're looking for
- source "file://#{gem_repo2}"
+ source "file://localhost#{gem_repo2}"
gem "rack"
G
- bundle "config --local mirror.file://#{gem_repo2} file://#{gem_repo1}"
+ 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:#{gem_repo1}")
- expect(out).not_to include("Fetching source index from file:#{gem_repo2}")
+ 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
diff --git a/spec/lock/lockfile_bundler_1_spec.rb b/spec/lock/lockfile_bundler_1_spec.rb
index 3be45e29dc..233e3f63c4 100644
--- a/spec/lock/lockfile_bundler_1_spec.rb
+++ b/spec/lock/lockfile_bundler_1_spec.rb
@@ -7,14 +7,14 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "generates a simple lockfile for a single source, gem" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -37,7 +37,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
specs:
GEM
- remote: file://#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -53,14 +53,14 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
L
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -80,7 +80,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
lockfile <<-L
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -95,14 +95,14 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
L
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -120,7 +120,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "updates the lockfile's bundler version if not present" do
lockfile <<-L
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -132,14 +132,14 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
L
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack", "> 0"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -157,7 +157,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "outputs a warning if the current is older than lockfile's bundler version" do
lockfile <<-L
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -173,7 +173,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
simulate_bundler_version "9999999.0.0" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
G
@@ -185,7 +185,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -204,7 +204,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "errors if the current is a major version older than lockfile's bundler version" do
lockfile <<-L
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -219,7 +219,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
L
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
G
@@ -269,7 +269,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "warns when updating bundler major version" do
lockfile <<-L
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -285,7 +285,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
simulate_bundler_version "9999999.0.0" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
G
@@ -296,7 +296,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -314,14 +314,14 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "generates a simple lockfile for a single source, gem with dependencies" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack-obama"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
rack-obama (1.0)
@@ -340,14 +340,14 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "generates a simple lockfile for a single source, gem with a version requirement" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack-obama", ">= 1.0"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
rack-obama (1.0)
@@ -396,13 +396,13 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "generates lockfiles with multiple requirements" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "net-sftp"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
net-sftp (1.1.1)
net-ssh (>= 1.0.0, < 1.99.0)
@@ -453,7 +453,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
build_lib "omg", :path => lib_path("omg")
gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
platforms :#{not_local_tag} do
gem "omg", :path => "#{lib_path("omg")}"
@@ -469,7 +469,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
specs:
GEM
- remote: file://#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -640,7 +640,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
bar = build_git "bar"
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
gem "foo", :path => "#{lib_path("foo-1.0")}"
@@ -660,7 +660,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
foo (1.0)
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -679,7 +679,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "lists gems alphabetically" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "thin"
gem "actionpack"
@@ -688,7 +688,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
actionpack (2.3.2)
activesupport (= 2.3.2)
@@ -714,14 +714,14 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "orders dependencies' dependencies in alphabetical order" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rails"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
actionmailer (2.3.2)
activesupport (= 2.3.2)
@@ -753,13 +753,13 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "orders dependencies by version" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem 'double_deps'
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
double_deps (1.0)
net-ssh
@@ -779,14 +779,14 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "does not add the :require option to the lockfile" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack-obama", ">= 1.0", :require => "rack/obama"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
rack-obama (1.0)
@@ -805,14 +805,14 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "does not add the :group option to the lockfile" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack-obama", ">= 1.0", :group => :test
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
rack-obama (1.0)
@@ -943,7 +943,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "keeps existing platforms in the lockfile" do
lockfile <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -958,7 +958,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
G
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
G
@@ -967,7 +967,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -991,13 +991,13 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
simulate_platform "universal-java-16"
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "platform_specific"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
platform_specific (1.0-java)
@@ -1014,19 +1014,19 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "does not add duplicate gems" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
G
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
gem "activesupport"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
activesupport (2.3.5)
rack (1.0.0)
@@ -1045,14 +1045,14 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "does not add duplicate dependencies" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
gem "rack"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -1069,14 +1069,14 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "does not add duplicate dependencies with versions" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack", "1.0"
gem "rack", "1.0"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -1093,14 +1093,14 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "does not add duplicate dependencies in different groups" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack", "1.0", :group => :one
gem "rack", "1.0", :group => :two
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -1117,7 +1117,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "raises if two different versions are used" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack", "1.0"
gem "rack", "1.1"
G
@@ -1128,7 +1128,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "raises if two different sources are used" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
gem "rack", :git => "git://hubz.com"
G
@@ -1139,13 +1139,13 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "works correctly with multiple version dependencies" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack", "> 0.9", "< 1.0"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (0.9.1)
@@ -1162,14 +1162,14 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "captures the Ruby version in the lockfile" do
install_gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
ruby '#{RUBY_VERSION}'
gem "rack", "> 0.9", "< 1.0"
G
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (0.9.1)
@@ -1198,7 +1198,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
revision = revision_for(lib_path("omg"))
gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "omg", :git => "#{lib_path("omg")}", :branch => 'master'
G
@@ -1222,7 +1222,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
omg (1.0)
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
PLATFORMS
@@ -1249,7 +1249,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
omg (1.0)
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
PLATFORMS
@@ -1266,7 +1266,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "raises a helpful error message when the lockfile is missing deps" do
lockfile <<-L
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack_middleware (1.0)
@@ -1295,7 +1295,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
build_repo2
install_gemfile <<-G
- source "file://#{gem_repo2}"
+ source "file://localhost#{gem_repo2}"
gem "rack"
G
set_lockfile_mtime_to_known_value
@@ -1357,7 +1357,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
it "refuses to install if Gemfile.lock contains conflict markers" do
lockfile <<-L
GEM
- remote: file://#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
<<<<<<<
rack (1.0.0)
@@ -1376,7 +1376,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
L
install_gemfile(<<-G)
- source "file://#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
G
diff --git a/spec/plugins/source/example_spec.rb b/spec/plugins/source/example_spec.rb
index 0dbd9a2a0f..fd30892f63 100644
--- a/spec/plugins/source/example_spec.rb
+++ b/spec/plugins/source/example_spec.rb
@@ -52,7 +52,7 @@ RSpec.describe "real source plugins" do
build_lib "a-path-gem"
gemfile <<-G
- source "file://#{gem_repo2}" # plugin source
+ source "file://localhost#{gem_repo2}" # plugin source
source "#{lib_path("a-path-gem-1.0")}", :type => :mpath do
gem "a-path-gem"
end
@@ -78,7 +78,7 @@ RSpec.describe "real source plugins" do
a-path-gem (1.0)
GEM
- remote: file:#{gem_repo2}/
+ remote: file://localhost#{gem_repo2}/
specs:
PLATFORMS
@@ -97,7 +97,7 @@ RSpec.describe "real source plugins" do
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo2}/
+ remote: file://localhost#{gem_repo2}/
specs:
PLUGIN SOURCE
@@ -346,7 +346,7 @@ RSpec.describe "real source plugins" do
build_git "ma-gitp-gem"
gemfile <<-G
- source "file://#{gem_repo2}" # plugin source
+ source "file://localhost#{gem_repo2}" # plugin source
source "file://#{lib_path("ma-gitp-gem-1.0")}", :type => :gitp do
gem "ma-gitp-gem"
end
@@ -372,7 +372,7 @@ RSpec.describe "real source plugins" do
ma-gitp-gem (1.0)
GEM
- remote: file:#{gem_repo2}/
+ remote: file://localhost#{gem_repo2}/
specs:
PLATFORMS
@@ -392,7 +392,7 @@ RSpec.describe "real source plugins" do
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo2}/
+ remote: file://localhost#{gem_repo2}/
specs:
PLUGIN SOURCE
diff --git a/spec/realworld/double_check_spec.rb b/spec/realworld/double_check_spec.rb
index 6fee578a71..94ab49ba2a 100644
--- a/spec/realworld/double_check_spec.rb
+++ b/spec/realworld/double_check_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "double checking sources", :realworld => true do
- it "finds already-installed gems" do
+ it "finds already-installed gems", :ruby => ">= 2.2" do
create_file("rails.gemspec", <<-RUBY)
Gem::Specification.new do |s|
s.name = "rails"
diff --git a/spec/runtime/gem_tasks_spec.rb b/spec/runtime/gem_tasks_spec.rb
index 884039e425..5fc87a6d46 100644
--- a/spec/runtime/gem_tasks_spec.rb
+++ b/spec/runtime/gem_tasks_spec.rb
@@ -36,7 +36,9 @@ RSpec.describe "require 'bundler/gem_tasks'" do
end
it "adds 'pkg' to rake/clean's CLOBBER" do
- require "bundler/gem_tasks"
- expect(CLOBBER).to include("pkg")
+ with_gem_path_as(Spec::Path.base_system_gems.to_s) do
+ sys_exec! %('#{Gem.ruby}' -S rake -e 'load "Rakefile"; puts CLOBBER.inspect')
+ end
+ expect(last_command.stdout).to eq '["pkg"]'
end
end
diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb
index 3eccd60fba..0484e38845 100644
--- a/spec/runtime/require_spec.rb
+++ b/spec/runtime/require_spec.rb
@@ -264,13 +264,13 @@ RSpec.describe "Bundler.require" do
describe "using bundle exec" do
it "requires the locked gems" do
- bundle "exec ruby -e 'Bundler.require'"
+ bundle "exec ruby -e 'Bundler.require'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to eq("two")
- bundle "exec ruby -e 'Bundler.require(:bar)'"
+ bundle "exec ruby -e 'Bundler.require(:bar)'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to eq("baz\nqux")
- bundle "exec ruby -e 'Bundler.require(:default, :bar)'"
+ bundle "exec ruby -e 'Bundler.require(:default, :bar)'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to eq("baz\nqux\ntwo")
end
end
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 7c84388766..e84cdaabf5 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -763,7 +763,7 @@ end
G
ENV["GEM_HOME"] = ""
- bundle %(exec ruby -e "require 'set'")
+ bundle %(exec ruby -e "require 'set'"), :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(err).to lack_errors
end
@@ -1078,7 +1078,7 @@ end
gem "bundler", :path => "#{File.expand_path("..", lib)}"
G
- bundle %(exec ruby -e "require 'bundler'; Bundler.setup")
+ bundle %(exec ruby -e "require 'bundler'; Bundler.setup"), :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(err).to lack_errors
end
end
@@ -1145,7 +1145,7 @@ end
def lock_with(ruby_version = nil)
lock = <<-L
GEM
- remote: file:#{gem_repo1}/
+ remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
@@ -1172,7 +1172,7 @@ end
before do
install_gemfile <<-G
ruby ">= 0"
- source "file:#{gem_repo1}"
+ source "file://localhost#{gem_repo1}"
gem "rack"
G
lockfile lock_with(ruby_version)
@@ -1236,6 +1236,7 @@ end
end
let(:activation_warning_hack) { strip_whitespace(<<-RUBY) }
+ require #{spec_dir.join("support/hax").to_s.dump}
require "rubygems"
if Gem::Specification.instance_methods.map(&:to_sym).include?(:activate)
@@ -1279,8 +1280,9 @@ end
it "activates no gems with bundle exec" do
install_gemfile! ""
+ # ensure we clean out the default gems, bceause bundler's allowed to be activated
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 + " -rbundler/setup" }
expect(last_command.stdout).to eq("{}")
end
diff --git a/spec/runtime/with_clean_env_spec.rb b/spec/runtime/with_clean_env_spec.rb
index b160e5b409..fd621071ad 100644
--- a/spec/runtime/with_clean_env_spec.rb
+++ b/spec/runtime/with_clean_env_spec.rb
@@ -1,6 +1,14 @@
# frozen_string_literal: true
RSpec.describe "Bundler.with_env helpers" do
+ def bundle_exec_ruby!(code, *args)
+ opts = args.last.is_a?(Hash) ? args.pop : {}
+ env = opts[:env] ||= {}
+ env[:RUBYOPT] ||= "-r#{spec_dir.join("support/hax")}"
+ args.push opts
+ bundle! "exec '#{Gem.ruby}' -e #{code}", *args
+ end
+
describe "Bundler.original_env" do
before do
bundle "config path vendor/bundle"
@@ -12,8 +20,8 @@ RSpec.describe "Bundler.with_env helpers" do
code = "print Bundler.original_env['PATH']"
path = `getconf PATH`.strip + "#{File::PATH_SEPARATOR}/foo"
with_path_as(path) do
- result = bundle("exec '#{Gem.ruby}' -e #{code.dump}")
- expect(result).to eq(path)
+ bundle_exec_ruby!(code.dump)
+ expect(last_command.stdboth).to eq(path)
end
end
@@ -21,8 +29,8 @@ RSpec.describe "Bundler.with_env helpers" do
code = "print Bundler.original_env['GEM_PATH']"
gem_path = ENV["GEM_PATH"] + ":/foo"
with_gem_path_as(gem_path) do
- result = bundle("exec '#{Gem.ruby}' -e #{code.inspect}")
- expect(result).to eq(gem_path)
+ bundle_exec_ruby!(code.dump)
+ expect(last_command.stdboth).to eq(gem_path)
end
end
@@ -38,7 +46,7 @@ RSpec.describe "Bundler.with_env helpers" do
RB
path = `getconf PATH`.strip + File::PATH_SEPARATOR + File.dirname(Gem.ruby)
with_path_as(path) do
- bundle!("exec '#{Gem.ruby}' #{bundled_app("exe.rb")} 2")
+ bundle! "exec '#{Gem.ruby}' #{bundled_app("exe.rb")} 2", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
end
expect(err).to eq <<-EOS.strip
2 false
@@ -48,10 +56,9 @@ RSpec.describe "Bundler.with_env helpers" do
end
it "removes variables that bundler added" do
- system_gems :bundler
- original = ruby!('puts ENV.to_a.map {|e| e.join("=") }.sort.join("\n")')
+ original = ruby!('puts ENV.to_a.map {|e| e.join("=") }.sort.join("\n")', :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" })
code = 'puts Bundler.original_env.to_a.map {|e| e.join("=") }.sort.join("\n")'
- bundle!("exec '#{Gem.ruby}' -e #{code.inspect}", :system_bundler => true)
+ bundle! "exec '#{Gem.ruby}' -e #{code.dump}", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
expect(out).to eq original
end
end
@@ -66,30 +73,30 @@ RSpec.describe "Bundler.with_env helpers" do
it "should delete BUNDLE_PATH" do
code = "print Bundler.clean_env.has_key?('BUNDLE_PATH')"
ENV["BUNDLE_PATH"] = "./foo"
- result = bundle("exec '#{Gem.ruby}' -e #{code.inspect}")
- expect(result).to eq("false")
+ bundle_exec_ruby! code.dump
+ expect(last_command.stdboth).to eq "false"
end
it "should remove '-rbundler/setup' from RUBYOPT" do
code = "print Bundler.clean_env['RUBYOPT']"
ENV["RUBYOPT"] = "-W2 -rbundler/setup"
- result = bundle("exec '#{Gem.ruby}' -e #{code.inspect}")
- expect(result).not_to include("-rbundler/setup")
+ bundle_exec_ruby! code.dump
+ expect(last_command.stdboth).not_to include("-rbundler/setup")
end
it "should clean up RUBYLIB" do
code = "print Bundler.clean_env['RUBYLIB']"
ENV["RUBYLIB"] = root.join("lib").to_s + File::PATH_SEPARATOR + "/foo"
- result = bundle("exec '#{Gem.ruby}' -e #{code.inspect}")
- expect(result).to eq("/foo")
+ bundle_exec_ruby! code.dump
+ expect(last_command.stdboth).to eq("/foo")
end
it "should restore the original MANPATH" do
code = "print Bundler.clean_env['MANPATH']"
ENV["MANPATH"] = "/foo"
ENV["BUNDLER_ORIG_MANPATH"] = "/foo-original"
- result = bundle("exec '#{Gem.ruby}' -e #{code.inspect}")
- expect(result).to eq("/foo-original")
+ bundle_exec_ruby! code.dump
+ expect(last_command.stdboth).to eq("/foo-original")
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 373fc6d4f4..18ba45da2c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -4,14 +4,16 @@ $:.unshift File.expand_path("..", __FILE__)
$:.unshift File.expand_path("../../lib", __FILE__)
require "rubygems"
-require "bundler/psyched_yaml"
-require "bundler/vendored_fileutils"
-require "uri"
-require "digest"
-require File.expand_path("../support/path.rb", __FILE__)
+module Gem
+ if defined?(@path_to_default_spec_map)
+ @path_to_default_spec_map.delete_if do |_path, spec|
+ spec.name == "bundler"
+ end
+ end
+end
begin
- require "rubygems"
+ require File.expand_path("../support/path.rb", __FILE__)
spec = Gem::Specification.load(Spec::Path.gemspec.to_s)
rspec = spec.dependencies.find {|d| d.name == "rspec" }
gem "rspec", rspec.requirement.to_s
@@ -21,6 +23,11 @@ rescue LoadError
abort "Run rake spec:deps to install development dependencies"
end
+require "bundler/psyched_yaml"
+require "bundler/vendored_fileutils"
+require "uri"
+require "digest"
+
if File.expand_path(__FILE__) =~ %r{([^\w/\.-])}
abort "The bundler specs cannot be run from a path that contains special characters (particularly #{$1.inspect})"
end
diff --git a/spec/support/builders.rb b/spec/support/builders.rb
index e8208eacd9..377ca35523 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -391,7 +391,7 @@ module Spec
index
end
- def build_spec(name, version, platform = nil, &block)
+ def build_spec(name, version = "0.0.1", platform = nil, &block)
Array(version).map do |v|
Gem::Specification.new do |s|
s.name = name
diff --git a/spec/support/hax.rb b/spec/support/hax.rb
index aee55a0ac9..b14e4a5943 100644
--- a/spec/support/hax.rb
+++ b/spec/support/hax.rb
@@ -12,6 +12,12 @@ module Gem
@local = new(ENV["BUNDLER_SPEC_PLATFORM"]) if ENV["BUNDLER_SPEC_PLATFORM"]
end
@platforms = [Gem::Platform::RUBY, Gem::Platform.local]
+
+ if defined?(@path_to_default_spec_map) && !ENV["BUNDLER_SPEC_KEEP_DEFAULT_BUNDLER_GEM"]
+ @path_to_default_spec_map.delete_if do |_path, spec|
+ spec.name == "bundler"
+ end
+ end
end
if ENV["BUNDLER_SPEC_VERSION"]
diff --git a/spec/update/git_spec.rb b/spec/update/git_spec.rb
index 52c4fc0957..b4cbb79434 100644
--- a/spec/update/git_spec.rb
+++ b/spec/update/git_spec.rb
@@ -291,7 +291,7 @@ RSpec.describe "bundle update" do
@git = build_git "foo", :path => lib_path("bar")
install_gemfile <<-G
- source "file://#{gem_repo2}"
+ source "file://localhost#{gem_repo2}"
git "#{lib_path("bar")}" do
gem 'foo'
end
@@ -319,7 +319,7 @@ RSpec.describe "bundle update" do
foo (2.0)
GEM
- remote: file:#{gem_repo2}/
+ remote: file://localhost#{gem_repo2}/
specs:
rack (1.0.0)
@@ -349,7 +349,7 @@ RSpec.describe "bundle update" do
lockfile_should_be <<-G
GEM
- remote: file:#{gem_repo2}/
+ remote: file://localhost#{gem_repo2}/
specs:
rack (1.0.0)