From 544e57cbe9bccd4f6e85c2ccea7e8d4a8c0f59fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sun, 12 Jan 2020 15:38:55 +0100 Subject: Pass a generic options hash to `sys_exec` For consistency with the rest of helpers. --- spec/commands/binstubs_spec.rb | 2 +- spec/commands/newgem_spec.rb | 2 +- spec/runtime/gem_tasks_spec.rb | 4 ++-- spec/runtime/setup_spec.rb | 2 +- spec/support/helpers.rb | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index 0c86e4cdb6..1d84b16524 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -137,7 +137,7 @@ RSpec.describe "bundle binstubs " do context "when BUNDLER_VERSION is set" do it "runs the correct version of bundler" do - sys_exec "#{bundled_app("bin/bundle")} install", "BUNDLER_VERSION" => "999.999.999" + sys_exec "#{bundled_app("bin/bundle")} install", :env => { "BUNDLER_VERSION" => "999.999.999" } expect(exitstatus).to eq(42) if exitstatus expect(err).to include("Activating bundler (~> 999.999) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`") diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb index 0bdf8ecba8..13d1e7abd7 100644 --- a/spec/commands/newgem_spec.rb +++ b/spec/commands/newgem_spec.rb @@ -232,7 +232,7 @@ RSpec.describe "bundle gem" do load_paths = [lib_dir, spec_dir] load_path_str = "-I#{load_paths.join(File::PATH_SEPARATOR)}" - sys_exec! "#{Gem.ruby} #{load_path_str} #{bindir.join("bundle")} gem #{gem_name}", "PATH" => "" + sys_exec! "#{Gem.ruby} #{load_path_str} #{bindir.join("bundle")} gem #{gem_name}", :env => { "PATH" => "" } end it "creates the gem without the need for git" do diff --git a/spec/runtime/gem_tasks_spec.rb b/spec/runtime/gem_tasks_spec.rb index f85f364865..91ea5cf189 100644 --- a/spec/runtime/gem_tasks_spec.rb +++ b/spec/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" => "-I#{lib_dir}" } 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" => "-I#{lib_dir}" } end expect(err).to be_empty diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 7ffddbd151..8c2c55ac5b 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -1375,7 +1375,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} -e \"puts require('bundler/setup')\"", :env => { "RUBYOPT" => "--disable=gems" }) expect(last_command.stdboth).to eq("true") end diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index fe142e62d9..4180a2f1ae 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -128,7 +128,7 @@ module Spec end.join cmd = "#{sudo} #{Gem.ruby} #{load_path_str} #{requires_str} #{bundle_bin} #{cmd}#{args}" - sys_exec(cmd, env, &block) + sys_exec(cmd, { :env => env }, &block) end bang :bundle @@ -155,9 +155,8 @@ module Spec end def ruby(ruby, options = {}) - env = options.delete(:env) || {} lib_option = options[:no_lib] ? "" : " -I#{lib_dir}" - sys_exec(%(#{Gem.ruby}#{lib_option} -w -e #{ruby.shellescape}), env) + sys_exec(%(#{Gem.ruby}#{lib_option} -w -e #{ruby.shellescape}), options) end bang :ruby @@ -189,7 +188,8 @@ module Spec "#{Gem.ruby} -S #{ENV["GEM_PATH"]}/bin/rake" end - def sys_exec(cmd, env = {}) + def sys_exec(cmd, options = {}) + env = options[:env] || {} command_execution = CommandExecution.new(cmd.to_s, Dir.pwd) require "open3" -- cgit v1.2.1