summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-08-15 18:58:07 +0200
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-08-16 08:43:55 +0200
commit948a863bd8ba237b71f647a4815eedb0befd9ab6 (patch)
tree0a9ab5787ef4791cb16523f48f773eed0ba7879b
parenta4beba4cbfc837f7b3b5fb35b95d0521255e8584 (diff)
downloadbundler-948a863bd8ba237b71f647a4815eedb0befd9ab6.tar.gz
Extract yet another helper method
-rw-r--r--spec/quality_spec.rb10
-rw-r--r--spec/support/helpers.rb29
2 files changed, 19 insertions, 20 deletions
diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb
index 5f00d4b6a0..40c0b0366e 100644
--- a/spec/quality_spec.rb
+++ b/spec/quality_spec.rb
@@ -225,16 +225,8 @@ RSpec.describe "The library itself" do
end
it "can still be built" do
- with_root_gemspec do |gemspec|
- Dir.chdir(root) { gem_command! :build, gemspec }
- end
-
- bundler_path = root.join("bundler-#{Bundler::VERSION}.gem")
-
- begin
+ with_built_bundler do |_gem_path|
expect(err).to be_empty, "bundler should build as a gem without warnings, but\n#{err}"
- ensure
- bundler_path.rmtree
end
end
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 6f982b4f4c..9cd468dfa1 100644
--- a/spec/support/helpers.rb
+++ b/spec/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