diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-08-15 18:58:07 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-08-17 17:08:51 +0900 |
commit | a2d7c97a9187f3d88230e273756ed4836fa8ac19 (patch) | |
tree | 72b1593145f88c46143338692fe706bf17cb63ab /spec/bundler/support/helpers.rb | |
parent | 43184056094af2495f05964c78bc517e07721802 (diff) | |
download | ruby-a2d7c97a9187f3d88230e273756ed4836fa8ac19.tar.gz |
[bundler/bundler] Extract yet another helper method
https://github.com/bundler/bundler/commit/948a863bd8
Diffstat (limited to 'spec/bundler/support/helpers.rb')
-rw-r--r-- | spec/bundler/support/helpers.rb | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb index 6f982b4f4c..9cd468dfa1 100644 --- a/spec/bundler/support/helpers.rb +++ b/spec/bundler/support/helpers.rb @@ -297,20 +297,13 @@ module Spec options = gems.last.is_a?(Hash) ? gems.pop : {} gem_repo = options.fetch(:gem_repo) { gem_repo1 } gems.each do |g| - path = if g == :bundler - with_root_gemspec do |gemspec| - Dir.chdir(root) { gem_command! :build, gemspec } - end - bundler_path = root.join("bundler-#{Bundler::VERSION}.gem") + if g == :bundler + with_built_bundler {|gem_path| install_gem(gem_path) } elsif g.to_s =~ %r{\A(?:[A-Z]:)?/.*\.gem\z} - g + install_gem(g) else - "#{gem_repo}/gems/#{g}.gem" + install_gem("#{gem_repo}/gems/#{g}.gem") end - - install_gem(path) - - bundler_path && bundler_path.rmtree end end @@ -320,6 +313,20 @@ module Spec gem_command! :install, "--no-document --ignore-dependencies '#{path}'" end + def with_built_bundler + with_root_gemspec do |gemspec| + Dir.chdir(root) { gem_command! :build, gemspec.to_s } + end + + bundler_path = root + "bundler-#{Bundler::VERSION}.gem" + + begin + yield(bundler_path) + ensure + bundler_path.rmtree + end + end + def with_gem_path_as(path) backup = ENV.to_hash ENV["GEM_HOME"] = path.to_s |