summaryrefslogtreecommitdiff
path: root/spec/runtime
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-12-16 15:11:44 -0600
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2017-12-21 16:48:43 +0900
commit2b24dead712cc823b4774ee4cd5444466b0df9e5 (patch)
tree65ca123e47a1a2dea0081f9b65defaa5d449c0d4 /spec/runtime
parent00e3e8cf51bd9cb5c202689df097918d7878166f (diff)
downloadbundler-2b24dead712cc823b4774ee4cd5444466b0df9e5.tar.gz
Try to get specs passing on old RubyGems
Diffstat (limited to 'spec/runtime')
-rw-r--r--spec/runtime/gem_tasks_spec.rb6
-rw-r--r--spec/runtime/require_spec.rb6
-rw-r--r--spec/runtime/setup_spec.rb8
-rw-r--r--spec/runtime/with_clean_env_spec.rb37
4 files changed, 35 insertions, 22 deletions
diff --git a/spec/runtime/gem_tasks_spec.rb b/spec/runtime/gem_tasks_spec.rb
index 884039e425..7bfd0e44a4 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}' -rrake -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 e8aa973ba8..d758232723 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
@@ -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..225e794eba 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
@@ -49,9 +57,10 @@ RSpec.describe "Bundler.with_env helpers" do
it "removes variables that bundler added" do
system_gems :bundler
+ system_gems :bundler, :path => :bundle_path # to ensure the bundler under test is the one activated...
original = ruby!('puts ENV.to_a.map {|e| e.join("=") }.sort.join("\n")')
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}", :system_bundler => true
expect(out).to eq original
end
end
@@ -66,30 +75,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