diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2018-12-18 12:32:00 +0100 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2018-12-19 10:26:43 +0100 |
commit | 25cf7000f3ea9f88de1bdc848e6237be384df7bc (patch) | |
tree | 5c7c01795a0280179c88c37669468bf132caebfd | |
parent | d8ecf00aab5b48005d1472d523276bff20950c34 (diff) | |
download | bundler-25cf7000f3ea9f88de1bdc848e6237be384df7bc.tar.gz |
Refactor hooks
So they only happen when needed.
-rw-r--r-- | spec/runtime/with_unbundled_env_spec.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/spec/runtime/with_unbundled_env_spec.rb b/spec/runtime/with_unbundled_env_spec.rb index 5351db8f07..ecccb1b0bb 100644 --- a/spec/runtime/with_unbundled_env_spec.rb +++ b/spec/runtime/with_unbundled_env_spec.rb @@ -2,6 +2,7 @@ RSpec.describe "Bundler.with_env helpers" do def bundle_exec_ruby!(code, *args) + build_bundler_context opts = args.last.is_a?(Hash) ? args.pop : {} env = opts[:env] ||= {} env[:RUBYOPT] ||= "-r#{spec_dir.join("support/hax")}" @@ -9,13 +10,13 @@ RSpec.describe "Bundler.with_env helpers" do bundle! "exec '#{Gem.ruby}' -e #{code}", *args end - describe "Bundler.original_env" do - before do - bundle "config path vendor/bundle" - gemfile "" - bundle "install" - end + def build_bundler_context + bundle "config path vendor/bundle" + gemfile "" + bundle "install" + end + describe "Bundler.original_env" do it "should return the PATH present before bundle was activated" do code = "print Bundler.original_env['PATH']" path = `getconf PATH`.strip + "#{File::PATH_SEPARATOR}/foo" @@ -46,6 +47,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 + build_bundler_context bundle! "exec '#{Gem.ruby}' #{bundled_app("exe.rb")} 2", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" } end expect(err).to eq <<-EOS.strip @@ -58,7 +60,7 @@ RSpec.describe "Bundler.with_env helpers" do it "removes variables that bundler added", :ruby_repo do 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.dump}", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" } + bundle_exec_ruby! code.dump expect(out).to eq original end end |