From 70dbb2ec1a9733dccf99f5e95933f1af9a1a71fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 5 Mar 2020 21:54:25 +0100 Subject: Extract common code to a method --- spec/support/helpers.rb | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index e556292774..b9b53fe279 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -374,11 +374,10 @@ module Spec end gems = gems.flatten - Gem.clear_paths - env_backup = ENV.to_hash - ENV["GEM_HOME"] = path.to_s - ENV["GEM_PATH"] = path.to_s + + set_gem_paths_to(path) + ENV["BUNDLER_ORIG_GEM_PATH"] = nil install_gems(*gems) @@ -396,13 +395,11 @@ module Spec FileUtils.rm_rf(system_gem_path) FileUtils.mkdir_p(system_gem_path) - Gem.clear_paths - gem_home = ENV["GEM_HOME"] gem_path = ENV["GEM_PATH"] path = ENV["PATH"] - ENV["GEM_HOME"] = system_gem_path.to_s - ENV["GEM_PATH"] = system_gem_path.to_s + + set_gem_paths_to(system_gem_path) gems.each do |gem| gem_command! "install --no-document #{gem}" @@ -417,6 +414,13 @@ module Spec end end + def set_gem_paths_to(path) + Gem.clear_paths + + ENV["GEM_HOME"] = path.to_s + ENV["GEM_PATH"] = path.to_s + end + def cache_gems(*gems) gems = gems.flatten -- cgit v1.2.1