summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-03-14 17:43:43 -0500
committerSamuel Giddins <segiddins@segiddins.me>2017-03-14 17:43:43 -0500
commita58bda0f3f9f5446b658c8682d265f569524b70c (patch)
tree62a303f9657681a45334e4b2b57a0d584a513f9b
parent44a087ce84e8a1beb24f39de8097e920b2ad18c3 (diff)
downloadbundler-seg-double-bundle-exec.tar.gz
Add a spec for nested bundle exec with a gem that shadows a default gemseg-double-bundle-exec
-rw-r--r--spec/commands/exec_spec.rb72
1 files changed, 57 insertions, 15 deletions
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index bf20ec7d9a..3c5f2ca1dd 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -646,23 +646,65 @@ __FILE__: #{path.to_s.inspect}
context "nested bundle exec" do
let(:system_gems_to_install) { super() << :bundler }
- before do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- G
- bundle :install, :system_bundler => true, :path => "vendor/bundler"
+
+ context "with shared gems disabled" do
+ before do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+ bundle :install, :system_bundler => true, :path => "vendor/bundler"
+ end
+
+ it "overrides disable_shared_gems so bundler can be found" do
+ file = bundled_app("file_that_bundle_execs.rb")
+ create_file(file, <<-RB)
+ #!#{Gem.ruby}
+ puts `bundle exec echo foo`
+ RB
+ file.chmod(0o777)
+ bundle! "exec #{file}", :system_bundler => true
+ expect(out).to eq("foo")
+ end
end
- it "overrides disable_shared_gems so bundler can be found" do
- file = bundled_app("file_that_bundle_execs.rb")
- create_file(file, <<-RB)
- #!#{Gem.ruby}
- puts `bundle exec echo foo`
- RB
- file.chmod(0o777)
- bundle! "exec #{file}", :system_bundler => true
- expect(out).to eq("foo")
+ context "with a system gem that shadows a default gem" do
+ let(:openssl_version) { "2.0.3" }
+ let(:expected) { ruby "gem 'openssl', '< 999999'; require 'openssl'; puts OpenSSL::VERSION", :artifice => nil }
+
+ it "only leaves the default gem in the stdlib available" do
+ skip "openssl isn't a default gem" if expected.empty?
+
+ install_gemfile! "" # must happen before installing the broken system gem
+
+ build_repo4 do
+ build_gem "openssl", openssl_version do |s|
+ s.write("lib/openssl.rb", <<-RB)
+ raise "custom openssl should not be loaded, it's not in the gemfile!"
+ RB
+ end
+ end
+
+ system_gems(:bundler, "openssl-#{openssl_version}", :gem_repo => gem_repo4)
+
+ file = bundled_app("require_openssl.rb")
+ create_file(file, <<-RB)
+ #!/usr/bin/env ruby
+ require "openssl"
+ puts OpenSSL::VERSION
+ RB
+ 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)
+ end
+
+ # sanity check that we get the newer, custom version without bundler
+ sys_exec(file.to_s)
+ expect(err).to include("custom openssl should not be loaded")
+ end
end
end
end