summaryrefslogtreecommitdiff
path: root/spec/bundler/runtime
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-21 09:22:15 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-21 09:22:15 +0000
commit4525cf2cd599389be3fab30ae4c13e22050705b5 (patch)
tree33165c2a9ec72863caa8c476e380e36eeb9c6a69 /spec/bundler/runtime
parent85277d5be0b24638ea4bf84c422e71a1219465e7 (diff)
Merge release version of bundler-1.16.1 from upstream.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/bundler/runtime')
-rw-r--r--spec/bundler/runtime/gem_tasks_spec.rb6
-rw-r--r--spec/bundler/runtime/require_spec.rb6
-rw-r--r--spec/bundler/runtime/setup_spec.rb8
-rw-r--r--spec/bundler/runtime/with_clean_env_spec.rb39
4 files changed, 35 insertions, 24 deletions
diff --git a/spec/bundler/runtime/gem_tasks_spec.rb b/spec/bundler/runtime/gem_tasks_spec.rb
index 500c3128fd..1cf808f35b 100644
--- a/spec/bundler/runtime/gem_tasks_spec.rb
+++ b/spec/bundler/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! %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect')
+ end
+ expect(last_command.stdout).to eq '["pkg"]'
end
end
diff --git a/spec/bundler/runtime/require_spec.rb b/spec/bundler/runtime/require_spec.rb
index 3eccd60fba..0484e38845 100644
--- a/spec/bundler/runtime/require_spec.rb
+++ b/spec/bundler/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/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb
index ec2da2be2f..97d2ea1918 100644
--- a/spec/bundler/runtime/setup_spec.rb
+++ b/spec/bundler/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
@@ -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/bundler/runtime/with_clean_env_spec.rb b/spec/bundler/runtime/with_clean_env_spec.rb
index 05b334c28a..c88da3cd02 100644
--- a/spec/bundler/runtime/with_clean_env_spec.rb
+++ b/spec/bundler/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", :ruby_repo 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", :ruby_repo 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