summaryrefslogtreecommitdiff
path: root/spec/bundler/runtime
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-05-08 14:19:04 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-05-13 07:54:37 +0900
commit0e60b59d5884edb8f9aea023efd9b24f1ff02049 (patch)
treee52935ce510440872ca5ce6b0e092cbc94f18bc9 /spec/bundler/runtime
parent68224651a4d4dc3ce0cea666f5423dd8b6ba6cfc (diff)
Update the bundler version with master branch
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3086
Diffstat (limited to 'spec/bundler/runtime')
-rw-r--r--spec/bundler/runtime/executable_spec.rb28
-rw-r--r--spec/bundler/runtime/gem_tasks_spec.rb10
-rw-r--r--spec/bundler/runtime/inline_spec.rb36
-rw-r--r--spec/bundler/runtime/load_spec.rb4
-rw-r--r--spec/bundler/runtime/platform_spec.rb3
-rw-r--r--spec/bundler/runtime/require_spec.rb10
-rw-r--r--spec/bundler/runtime/setup_spec.rb53
-rw-r--r--spec/bundler/runtime/with_unbundled_env_spec.rb110
8 files changed, 148 insertions, 106 deletions
diff --git a/spec/bundler/runtime/executable_spec.rb b/spec/bundler/runtime/executable_spec.rb
index 003be97cd6..e420594f52 100644
--- a/spec/bundler/runtime/executable_spec.rb
+++ b/spec/bundler/runtime/executable_spec.rb
@@ -9,6 +9,8 @@ RSpec.describe "Running bin/* commands" do
end
it "runs the bundled command when in the bundle" do
+ skip "exec format error" if Gem.win_platform?
+
bundle! "binstubs rack"
build_gem "rack", "2.0", :to_system => true do |s|
@@ -20,6 +22,8 @@ RSpec.describe "Running bin/* commands" do
end
it "allows the location of the gem stubs to be specified" do
+ skip "created in bin :/" if Gem.win_platform?
+
bundle! "binstubs rack", :path => "gbin"
expect(bundled_app("bin")).not_to exist
@@ -30,6 +34,8 @@ RSpec.describe "Running bin/* commands" do
end
it "allows absolute paths as a specification of where to install bin stubs" do
+ skip "exec format error" if Gem.win_platform?
+
bundle! "binstubs rack", :path => tmp("bin")
gembin tmp("bin/rackup")
@@ -38,28 +44,32 @@ RSpec.describe "Running bin/* commands" do
it "uses the default ruby install name when shebang is not specified" do
bundle! "binstubs rack"
- expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env #{RbConfig::CONFIG["ruby_install_name"]}\n")
+ expect(File.open(bundled_app("bin/rackup")).gets).to eq("#!/usr/bin/env #{RbConfig::CONFIG["ruby_install_name"]}\n")
end
it "allows the name of the shebang executable to be specified" do
+ skip "not created with custom name :/" if Gem.win_platform?
+
bundle! "binstubs rack", :shebang => "ruby-foo"
- expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env ruby-foo\n")
+ expect(File.open(bundled_app("bin/rackup")).gets).to eq("#!/usr/bin/env ruby-foo\n")
end
it "runs the bundled command when out of the bundle" do
+ skip "exec format error" if Gem.win_platform?
+
bundle! "binstubs rack"
build_gem "rack", "2.0", :to_system => true do |s|
s.executables = "rackup"
end
- Dir.chdir(tmp) do
- gembin "rackup"
- expect(out).to eq("1.0.0")
- end
+ gembin "rackup", :dir => tmp
+ expect(out).to eq("1.0.0")
end
it "works with gems in path" do
+ skip "exec format error" if Gem.win_platform?
+
build_lib "rack", :path => lib_path("rack") do |s|
s.executables = "rackup"
end
@@ -94,12 +104,16 @@ RSpec.describe "Running bin/* commands" do
end
it "does not generate bin stubs if the option was not specified" do
+ skip "generated :/" if Gem.win_platform?
+
bundle! "install"
expect(bundled_app("bin/rackup")).not_to exist
end
it "allows you to stop installing binstubs", :bundler => "< 3" do
+ skip "delete permission error" if Gem.win_platform?
+
bundle! "install --binstubs bin/"
bundled_app("bin/rackup").rmtree
bundle! "install --binstubs \"\""
@@ -143,6 +157,8 @@ RSpec.describe "Running bin/* commands" do
end
it "use BUNDLE_GEMFILE gemfile for binstub" do
+ skip "exec format error" if Gem.win_platform?
+
# context with bin/bundler w/ default Gemfile
bundle! "binstubs bundler"
diff --git a/spec/bundler/runtime/gem_tasks_spec.rb b/spec/bundler/runtime/gem_tasks_spec.rb
index 74270a2316..9d673bb9cc 100644
--- a/spec/bundler/runtime/gem_tasks_spec.rb
+++ b/spec/bundler/runtime/gem_tasks_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe "require 'bundler/gem_tasks'" do
it "includes the relevant tasks" do
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
- sys_exec "#{rake} -T", "RUBYOPT" => "-I#{lib_dir}"
+ sys_exec "#{rake} -T", :env => { "RUBYOPT" => opt_add("-I#{lib_dir}", ENV["RUBYOPT"]) }
end
expect(err).to be_empty
@@ -47,7 +47,7 @@ RSpec.describe "require 'bundler/gem_tasks'" do
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}"
+ sys_exec "#{rake} install", :env => { "RUBYOPT" => opt_add("-I#{lib_dir}", ENV["RUBYOPT"]) }
end
expect(err).to be_empty
@@ -60,13 +60,11 @@ RSpec.describe "require 'bundler/gem_tasks'" do
context "rake build when path has spaces" do
before do
spaced_bundled_app = tmp.join("bundled app")
- FileUtils.mv bundled_app, spaced_bundled_app
- Dir.chdir(spaced_bundled_app)
+ FileUtils.cp_r bundled_app, spaced_bundled_app
+ bundle! "exec rake build", :dir => spaced_bundled_app
end
it "still runs successfully" do
- bundle! "exec rake build"
-
expect(err).to be_empty
end
end
diff --git a/spec/bundler/runtime/inline_spec.rb b/spec/bundler/runtime/inline_spec.rb
index cd762fe636..fb6c6e90ad 100644
--- a/spec/bundler/runtime/inline_spec.rb
+++ b/spec/bundler/runtime/inline_spec.rb
@@ -46,6 +46,8 @@ RSpec.describe "bundler/inline#gemfile" do
end
it "requires the gems" do
+ skip "gems not found" if Gem.win_platform?
+
script <<-RUBY
gemfile do
path "#{lib_path}" do
@@ -95,6 +97,8 @@ RSpec.describe "bundler/inline#gemfile" do
end
it "lets me use my own ui object" do
+ skip "prints just one CONFIRMED" if Gem.win_platform?
+
script <<-RUBY, :artifice => "endpoint"
require '#{lib_dir}/bundler'
class MyBundlerUI < Bundler::UI::Silent
@@ -229,16 +233,14 @@ RSpec.describe "bundler/inline#gemfile" do
1.13.6
G
- in_app_root do
- script <<-RUBY
- gemfile do
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- end
+ script <<-RUBY
+ gemfile do
+ source "#{file_uri_for(gem_repo1)}"
+ gem "rack"
+ end
- puts RACK
- RUBY
- end
+ puts RACK
+ RUBY
expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
@@ -261,16 +263,14 @@ RSpec.describe "bundler/inline#gemfile" do
it "installs inline gems when BUNDLE_GEMFILE is set to an empty string" do
ENV["BUNDLE_GEMFILE"] = ""
- in_app_root do
- script <<-RUBY
- gemfile do
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- end
+ script <<-RUBY
+ gemfile do
+ source "#{file_uri_for(gem_repo1)}"
+ gem "rack"
+ end
- puts RACK
- RUBY
- end
+ puts RACK
+ RUBY
expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
diff --git a/spec/bundler/runtime/load_spec.rb b/spec/bundler/runtime/load_spec.rb
index 7de67e247c..a406fbaf49 100644
--- a/spec/bundler/runtime/load_spec.rb
+++ b/spec/bundler/runtime/load_spec.rb
@@ -7,6 +7,7 @@ RSpec.describe "Bundler.load" do
source "#{file_uri_for(gem_repo1)}"
gem "rack"
G
+ allow(Bundler::SharedHelpers).to receive(:pwd).and_return(bundled_app)
end
it "provides a list of the env dependencies" do
@@ -32,6 +33,7 @@ RSpec.describe "Bundler.load" do
gem "rack"
G
bundle! :install
+ allow(Bundler::SharedHelpers).to receive(:pwd).and_return(bundled_app)
end
it "provides a list of the env dependencies" do
@@ -101,7 +103,7 @@ RSpec.describe "Bundler.load" do
source "#{file_uri_for(gem_repo1)}"
gem "activerecord"
G
-
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
Bundler.load.specs.each do |spec|
expect(spec.to_yaml).not_to match(/^\s+source:/)
expect(spec.to_yaml).not_to match(/^\s+groups:/)
diff --git a/spec/bundler/runtime/platform_spec.rb b/spec/bundler/runtime/platform_spec.rb
index f7e93eacf1..70c7594395 100644
--- a/spec/bundler/runtime/platform_spec.rb
+++ b/spec/bundler/runtime/platform_spec.rb
@@ -113,11 +113,12 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
bundle! "install"
expect(the_bundle).to include_gems "platform_specific 1.0 RUBY"
+ expect(the_bundle).to not_include_gems "nokogiri"
end
end
it "allows specifying only-ruby-platform on windows with gemspec dependency" do
- build_lib("foo", "1.0", :path => ".") do |s|
+ build_lib("foo", "1.0", :path => bundled_app) do |s|
s.add_dependency "rack"
end
diff --git a/spec/bundler/runtime/require_spec.rb b/spec/bundler/runtime/require_spec.rb
index a8d7826123..3b9021b4fc 100644
--- a/spec/bundler/runtime/require_spec.rb
+++ b/spec/bundler/runtime/require_spec.rb
@@ -155,7 +155,7 @@ RSpec.describe "Bundler.require" do
begin
Bundler.require
rescue LoadError => e
- $stderr.puts "ZOMG LOAD ERROR: \#{e.message}"
+ warn "ZOMG LOAD ERROR: \#{e.message}"
end
RUBY
run(cmd)
@@ -228,7 +228,7 @@ RSpec.describe "Bundler.require" do
begin
Bundler.require
rescue LoadError => e
- $stderr.puts "ZOMG LOAD ERROR" if e.message.include?("Could not open library 'libfuuu-1.0'")
+ warn "ZOMG LOAD ERROR" if e.message.include?("Could not open library 'libfuuu-1.0'")
end
RUBY
run(cmd)
@@ -251,7 +251,7 @@ RSpec.describe "Bundler.require" do
begin
Bundler.require
rescue LoadError => e
- $stderr.puts "ZOMG LOAD ERROR: \#{e.message}"
+ warn "ZOMG LOAD ERROR: \#{e.message}"
end
RUBY
run(cmd)
@@ -423,7 +423,7 @@ RSpec.describe "Bundler.require with platform specific dependencies" do
source "#{file_uri_for(gem_repo1)}"
platforms :#{not_local_tag} do
- gem "fail", :require => "omgomg"
+ gem "platform_specific", :require => "omgomg"
end
gem "rack", "1.0.0"
@@ -434,6 +434,8 @@ RSpec.describe "Bundler.require with platform specific dependencies" do
end
it "requires gems pinned to multiple platforms, including the current one" do
+ skip "platform issues" if Gem.win_platform?
+
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb
index 7f00a63078..b39a740653 100644
--- a/spec/bundler/runtime/setup_spec.rb
+++ b/spec/bundler/runtime/setup_spec.rb
@@ -159,7 +159,7 @@ RSpec.describe "Bundler.setup" do
"/gems/actionpack-2.3.2/lib",
"/gems/actionmailer-2.3.2/lib",
"/gems/activesupport-2.3.2/lib",
- "/gems/rake-12.3.2/lib"
+ "/gems/rake-13.0.1/lib"
)
end
@@ -218,7 +218,7 @@ RSpec.describe "Bundler.setup" do
Bundler.setup
R
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
end
it "doesn't change the Gemfile.lock if the setup fails" do
@@ -227,7 +227,7 @@ RSpec.describe "Bundler.setup" do
gem "rack"
G
- lockfile = File.read(bundled_app("Gemfile.lock"))
+ lockfile = File.read(bundled_app_lock)
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@@ -241,7 +241,7 @@ RSpec.describe "Bundler.setup" do
Bundler.setup
R
- expect(File.read(bundled_app("Gemfile.lock"))).to eq(lockfile)
+ expect(File.read(bundled_app_lock)).to eq(lockfile)
end
it "makes a Gemfile.lock if setup succeeds" do
@@ -250,12 +250,12 @@ RSpec.describe "Bundler.setup" do
gem "rack"
G
- File.read(bundled_app("Gemfile.lock"))
+ File.read(bundled_app_lock)
- FileUtils.rm(bundled_app("Gemfile.lock"))
+ FileUtils.rm(bundled_app_lock)
run "1"
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
describe "$BUNDLE_GEMFILE" do
@@ -460,7 +460,7 @@ RSpec.describe "Bundler.setup" do
it "provides a good exception if the lockfile is unavailable" do
bundle "install"
- FileUtils.rm(bundled_app("Gemfile.lock"))
+ FileUtils.rm(bundled_app_lock)
break_git!
@@ -489,15 +489,16 @@ RSpec.describe "Bundler.setup" do
it "does not randomly change the path when specifying --path and the bundle directory becomes read only" do
bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
- with_read_only("**/*") do
+ with_read_only("#{bundled_app}/**/*") do
expect(the_bundle).to include_gems "rack 1.0.0"
end
end
it "finds git gem when default bundle path becomes read only" do
+ bundle "config set --local path .bundle"
bundle "install"
- with_read_only("#{Bundler.bundle_path}/**/*") do
+ with_read_only("#{bundled_app(".bundle")}/**/*") do
expect(the_bundle).to include_gems "rack 1.0.0"
end
end
@@ -708,7 +709,7 @@ end
end
context "when the user has one set" do
- before { ENV["MANPATH"] = "/foo:" }
+ before { ENV["MANPATH"] = "/foo#{File::PATH_SEPARATOR}" }
it "adds the gem's man dir to the MANPATH" do
install_gemfile! <<-G
@@ -717,7 +718,7 @@ end
G
run! "puts ENV['MANPATH']"
- expect(out).to eq("#{default_bundle_path("gems/with_man-1.0/man")}:/foo")
+ expect(out).to eq("#{default_bundle_path("gems/with_man-1.0/man")}#{File::PATH_SEPARATOR}/foo")
end
end
@@ -793,6 +794,8 @@ end
let(:full_name) { "bundler-#{Bundler::VERSION}" }
before do
+ skip "symlink destination exists" if Gem.win_platform?
+
FileUtils.ln_sf(gem_home, symlinked_gem_home)
gems_dir = File.join(gem_home, "gems")
specifications_dir = File.join(gem_home, "specifications")
@@ -863,11 +866,9 @@ end
gem 'foo', '1.2.3', :path => 'vendor/foo'
G
- Dir.chdir(bundled_app.parent) do
- run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile").to_s }
- require 'foo'
- R
- end
+ run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app_gemfile.to_s }, :dir => bundled_app.parent
+ require 'foo'
+ R
expect(err).to be_empty
end
@@ -887,11 +888,9 @@ end
bundle :install
- Dir.chdir(bundled_app.parent) do
- run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile").to_s }
- require 'foo'
- R
- end
+ run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app_gemfile.to_s }, :dir => bundled_app.parent
+ require 'foo'
+ R
expect(err).to be_empty
end
@@ -1015,6 +1014,8 @@ end
end
it "error intelligently if the gemspec has a LoadError" do
+ skip "whitespace issue?" if Gem.win_platform?
+
ref = update_git "bar", :gemspec => false do |s|
s.write "bar.gemspec", "require 'foobarbaz'"
end.ref_for("HEAD")
@@ -1202,11 +1203,13 @@ end
describe "default gem activation" do
let(:exemptions) do
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7")
+ exempts = if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7")
%w[did_you_mean]
else
%w[io-console openssl]
end << "bundler"
+ exempts << "fiddle" if Gem.win_platform? && Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7")
+ exempts
end
let(:activation_warning_hack) { strip_whitespace(<<-RUBY) }
@@ -1256,6 +1259,8 @@ end
end
it "activates no gems with bundle exec that is loaded" do
+ skip "not executable" if Gem.win_platform?
+
install_gemfile! ""
create_file("script.rb", "#!/usr/bin/env ruby\n\n#{code}")
FileUtils.chmod(0o777, bundled_app("script.rb"))
@@ -1367,7 +1372,7 @@ end
end
it "takes care of requiring rubygems" do
- sys_exec("#{Gem.ruby} -I#{lib_dir} -e \"puts require('bundler/setup')\"", "RUBYOPT" => "--disable=gems")
+ sys_exec("#{Gem.ruby} -I#{lib_dir} -rbundler/setup -e'puts true'", :env => { "RUBYOPT" => opt_add("--disable=gems", ENV["RUBYOPT"]) })
expect(last_command.stdboth).to eq("true")
end
diff --git a/spec/bundler/runtime/with_unbundled_env_spec.rb b/spec/bundler/runtime/with_unbundled_env_spec.rb
index 4aaf9d499c..80c5d92b76 100644
--- a/spec/bundler/runtime/with_unbundled_env_spec.rb
+++ b/spec/bundler/runtime/with_unbundled_env_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
RSpec.describe "Bundler.with_env helpers" do
- def bundle_exec_ruby!(code, options = {})
+ def bundle_exec_ruby!(args, options = {})
build_bundler_context options
- bundle! "exec '#{Gem.ruby}' -e #{code}", options
+ bundle! "exec '#{Gem.ruby}' #{args}", options
end
def build_bundler_context(options = {})
@@ -12,39 +12,47 @@ RSpec.describe "Bundler.with_env helpers" do
bundle "install", options
end
+ def run_bundler_script(env, script)
+ system(env, "ruby", "-I#{lib_dir}", "-rbundler", script.to_s)
+ end
+
describe "Bundler.original_env" do
it "should return the PATH present before bundle was activated" do
- code = "print Bundler.original_env['PATH']"
+ create_file("source.rb", <<-RUBY)
+ print Bundler.original_env["PATH"]
+ RUBY
path = `getconf PATH`.strip + "#{File::PATH_SEPARATOR}/foo"
with_path_as(path) do
- bundle_exec_ruby!(code.dump)
+ bundle_exec_ruby!(bundled_app("source.rb").to_s)
expect(last_command.stdboth).to eq(path)
end
end
it "should return the GEM_PATH present before bundle was activated" do
- code = "print Bundler.original_env['GEM_PATH']"
- gem_path = ENV["GEM_PATH"] + ":/foo"
+ create_file("source.rb", <<-RUBY)
+ print Bundler.original_env['GEM_PATH']
+ RUBY
+ gem_path = ENV["GEM_PATH"] + "#{File::PATH_SEPARATOR}/foo"
with_gem_path_as(gem_path) do
- bundle_exec_ruby!(code.dump)
+ bundle_exec_ruby!(bundled_app("source.rb").to_s)
expect(last_command.stdboth).to eq(gem_path)
end
end
it "works with nested bundle exec invocations" do
- create_file("exe.rb", <<-'RB')
+ create_file("exe.rb", <<-'RUBY')
count = ARGV.first.to_i
exit if count < 0
- STDERR.puts "#{count} #{ENV["PATH"].end_with?(":/foo")}"
+ STDERR.puts "#{count} #{ENV["PATH"].end_with?("#{File::PATH_SEPARATOR}/foo")}"
if count == 2
- ENV["PATH"] = "#{ENV["PATH"]}:/foo"
+ ENV["PATH"] = "#{ENV["PATH"]}#{File::PATH_SEPARATOR}/foo"
end
exec(Gem.ruby, __FILE__, (count - 1).to_s)
- RB
+ RUBY
path = `getconf PATH`.strip + File::PATH_SEPARATOR + File.dirname(Gem.ruby)
with_path_as(path) do
build_bundler_context
- bundle! "exec '#{Gem.ruby}' #{bundled_app("exe.rb")} 2"
+ bundle_exec_ruby!("#{bundled_app("exe.rb")} 2")
end
expect(err).to eq <<-EOS.strip
2 false
@@ -58,40 +66,50 @@ RSpec.describe "Bundler.with_env helpers" do
ENV.replace(ENV.to_hash.delete_if {|k, _v| k.start_with?(Bundler::EnvironmentPreserver::BUNDLER_PREFIX) })
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_ruby! code.dump
+ create_file("source.rb", <<-RUBY)
+ puts Bundler.original_env.to_a.map {|e| e.join("=") }.sort.join("\n")
+ RUBY
+ bundle_exec_ruby! bundled_app("source.rb")
expect(out).to eq original
end
end
shared_examples_for "an unbundling helper" do
it "should delete BUNDLE_PATH" do
- code = "print #{modified_env}.has_key?('BUNDLE_PATH')"
+ create_file("source.rb", <<-RUBY)
+ print #{modified_env}.has_key?('BUNDLE_PATH')
+ RUBY
ENV["BUNDLE_PATH"] = "./foo"
- bundle_exec_ruby! code.dump
+ bundle_exec_ruby! bundled_app("source.rb")
expect(last_command.stdboth).to include "false"
end
it "should remove '-rbundler/setup' from RUBYOPT" do
- code = "print #{modified_env}['RUBYOPT']"
+ create_file("source.rb", <<-RUBY)
+ print #{modified_env}['RUBYOPT']
+ RUBY
ENV["RUBYOPT"] = "-W2 -rbundler/setup #{ENV["RUBYOPT"]}"
- bundle_exec_ruby! code.dump, :env => { "BUNDLER_SPEC_DISABLE_DEFAULT_BUNDLER_GEM" => "true" }
+ bundle_exec_ruby! bundled_app("source.rb"), :env => { "BUNDLER_SPEC_DISABLE_DEFAULT_BUNDLER_GEM" => "true" }
expect(last_command.stdboth).not_to include("-rbundler/setup")
end
it "should restore RUBYLIB", :ruby_repo do
- code = "print #{modified_env}['RUBYLIB']"
+ create_file("source.rb", <<-RUBY)
+ print #{modified_env}['RUBYLIB']
+ RUBY
ENV["RUBYLIB"] = lib_dir.to_s + File::PATH_SEPARATOR + "/foo"
ENV["BUNDLER_ORIG_RUBYLIB"] = lib_dir.to_s + File::PATH_SEPARATOR + "/foo-original"
- bundle_exec_ruby! code.dump
+ bundle_exec_ruby! bundled_app("source.rb")
expect(last_command.stdboth).to include("/foo-original")
end
it "should restore the original MANPATH" do
- code = "print #{modified_env}['MANPATH']"
+ create_file("source.rb", <<-RUBY)
+ print #{modified_env}['MANPATH']
+ RUBY
ENV["MANPATH"] = "/foo"
ENV["BUNDLER_ORIG_MANPATH"] = "/foo-original"
- bundle_exec_ruby! code.dump
+ bundle_exec_ruby! bundled_app("source.rb")
expect(last_command.stdboth).to include("/foo-original")
end
end
@@ -111,7 +129,7 @@ RSpec.describe "Bundler.with_env helpers" do
describe "Bundler.with_original_env" do
it "should set ENV to original_env in the block" do
expected = Bundler.original_env
- actual = Bundler.with_original_env { ENV.to_hash }
+ actual = Bundler.with_original_env { Bundler::EnvironmentPreserver.env_to_hash(ENV) }
expect(actual).to eq(expected)
end
@@ -129,7 +147,7 @@ RSpec.describe "Bundler.with_env helpers" do
expected = Bundler.unbundled_env
actual = Bundler.ui.silence do
- Bundler.with_clean_env { ENV.to_hash }
+ Bundler.with_clean_env { Bundler::EnvironmentPreserver.env_to_hash(ENV) }
end
expect(actual).to eq(expected)
@@ -147,7 +165,7 @@ RSpec.describe "Bundler.with_env helpers" do
describe "Bundler.with_unbundled_env" do
it "should set ENV to unbundled_env in the block" do
expected = Bundler.unbundled_env
- actual = Bundler.with_unbundled_env { ENV.to_hash }
+ actual = Bundler.with_unbundled_env { Bundler::EnvironmentPreserver.env_to_hash(ENV) }
expect(actual).to eq(expected)
end
@@ -161,53 +179,53 @@ RSpec.describe "Bundler.with_env helpers" do
end
describe "Bundler.original_system" do
- let(:code) do
- <<~RUBY
- Bundler.original_system(%([ "\$BUNDLE_FOO" = "bar" ] && exit 42))
+ before do
+ create_file("source.rb", <<-'RUBY')
+ Bundler.original_system("ruby", "-e", "exit(42) if ENV['BUNDLE_FOO'] == 'bar'")
exit $?.exitstatus
RUBY
end
it "runs system inside with_original_env" do
- system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib_dir} -rbundler -e '#{code}'")
+ run_bundler_script({ "BUNDLE_FOO" => "bar" }, bundled_app("source.rb"))
expect($?.exitstatus).to eq(42)
end
end
describe "Bundler.clean_system", :bundler => 2 do
- let(:code) do
- <<~RUBY
- Bundler.ui.silence { Bundler.clean_system(%([ "\$BUNDLE_FOO" = "bar" ] || exit 42)) }
+ before do
+ create_file("source.rb", <<-'RUBY')
+ Bundler.ui.silence { Bundler.clean_system("ruby", "-e", "exit(42) unless ENV['BUNDLE_FOO'] == 'bar'") }
exit $?.exitstatus
RUBY
end
it "runs system inside with_clean_env" do
- system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib_dir} -rbundler -e '#{code}'")
+ run_bundler_script({ "BUNDLE_FOO" => "bar" }, bundled_app("source.rb"))
expect($?.exitstatus).to eq(42)
end
end
describe "Bundler.unbundled_system" do
- let(:code) do
- <<~RUBY
- Bundler.unbundled_system(%([ "\$BUNDLE_FOO" = "bar" ] || exit 42))
+ before do
+ create_file("source.rb", <<-'RUBY')
+ Bundler.unbundled_system("ruby", "-e", "exit(42) unless ENV['BUNDLE_FOO'] == 'bar'")
exit $?.exitstatus
RUBY
end
it "runs system inside with_unbundled_env" do
- system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib_dir} -rbundler -e '#{code}'")
+ run_bundler_script({ "BUNDLE_FOO" => "bar" }, bundled_app("source.rb"))
expect($?.exitstatus).to eq(42)
end
end
describe "Bundler.original_exec" do
- let(:code) do
- <<~RUBY
+ before do
+ create_file("source.rb", <<-'RUBY')
Process.fork do
exit Bundler.original_exec(%(test "\$BUNDLE_FOO" = "bar"))
end
@@ -221,14 +239,14 @@ RSpec.describe "Bundler.with_env helpers" do
it "runs exec inside with_original_env" do
skip "Fork not implemented" if Gem.win_platform?
- system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib_dir} -rbundler -e '#{code}'")
+ run_bundler_script({ "BUNDLE_FOO" => "bar" }, bundled_app("source.rb"))
expect($?.exitstatus).to eq(0)
end
end
describe "Bundler.clean_exec", :bundler => 2 do
- let(:code) do
- <<~RUBY
+ before do
+ create_file("source.rb", <<-'RUBY')
Process.fork do
exit Bundler.ui.silence { Bundler.clean_exec(%(test "\$BUNDLE_FOO" = "bar")) }
end
@@ -242,14 +260,14 @@ RSpec.describe "Bundler.with_env helpers" do
it "runs exec inside with_clean_env" do
skip "Fork not implemented" if Gem.win_platform?
- system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib_dir} -rbundler -e '#{code}'")
+ run_bundler_script({ "BUNDLE_FOO" => "bar" }, bundled_app("source.rb"))
expect($?.exitstatus).to eq(1)
end
end
describe "Bundler.unbundled_exec" do
- let(:code) do
- <<~RUBY
+ before do
+ create_file("source.rb", <<-'RUBY')
Process.fork do
exit Bundler.unbundled_exec(%(test "\$BUNDLE_FOO" = "bar"))
end
@@ -263,7 +281,7 @@ RSpec.describe "Bundler.with_env helpers" do
it "runs exec inside with_clean_env" do
skip "Fork not implemented" if Gem.win_platform?
- system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib_dir} -rbundler -e '#{code}'")
+ run_bundler_script({ "BUNDLE_FOO" => "bar" }, bundled_app("source.rb"))
expect($?.exitstatus).to eq(1)
end
end