summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-03-05 21:54:25 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2020-03-06 14:01:37 +0100
commit70dbb2ec1a9733dccf99f5e95933f1af9a1a71fd (patch)
tree46c251ab6662f7e94df66cd9bbb0ea97f32f8094
parente687f448023b8c9d84f0bb42b8dc5019fa189200 (diff)
downloadbundler-70dbb2ec1a9733dccf99f5e95933f1af9a1a71fd.tar.gz
Extract common code to a method
-rw-r--r--spec/support/helpers.rb20
1 files 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