diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-08-15 18:53:51 +0200 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-08-16 08:43:54 +0200 |
commit | f20c2bdf6a877eb1ad6e0b90f6483cef3480fee8 (patch) | |
tree | e4a573a731e78cf49c4879eda8f78c311c6b953c | |
parent | 07161ebc1a271de20510a25b4ab9568aae1af871 (diff) | |
download | bundler-f20c2bdf6a877eb1ad6e0b90f6483cef3480fee8.tar.gz |
Extract a `with_root_gemspec` helper
-rw-r--r-- | spec/quality_spec.rb | 8 | ||||
-rw-r--r-- | spec/support/helpers.rb | 8 | ||||
-rw-r--r-- | spec/support/path.rb | 12 |
3 files changed, 14 insertions, 14 deletions
diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index 40e1a113f0..5f00d4b6a0 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -225,13 +225,7 @@ RSpec.describe "The library itself" do end it "can still be built" do - if ruby_core? - spec = Gem::Specification.load(gemspec.to_s) - spec.bindir = "libexec" - File.open(root.join("bundler.gemspec").to_s, "w") {|f| f.write spec.to_ruby } - Dir.chdir(root) { gem_command! :build, root.join("bundler.gemspec") } - FileUtils.rm(root.join("bundler.gemspec")) - else + with_root_gemspec do |gemspec| Dir.chdir(root) { gem_command! :build, gemspec } end diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 058c7a893d..6f982b4f4c 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -298,13 +298,7 @@ module Spec gem_repo = options.fetch(:gem_repo) { gem_repo1 } gems.each do |g| path = if g == :bundler - if ruby_core? - spec = Gem::Specification.load(gemspec.to_s) - spec.bindir = "libexec" - File.open(root.join("bundler.gemspec").to_s, "w") {|f| f.write spec.to_ruby } - Dir.chdir(root) { gem_command! :build, root.join("bundler.gemspec") } - FileUtils.rm(root.join("bundler.gemspec")) - else + with_root_gemspec do |gemspec| Dir.chdir(root) { gem_command! :build, gemspec } end bundler_path = root.join("bundler-#{Bundler::VERSION}.gem") diff --git a/spec/support/path.rb b/spec/support/path.rb index 3b18cd2da8..38d8ff8102 100644 --- a/spec/support/path.rb +++ b/spec/support/path.rb @@ -132,6 +132,18 @@ module Spec tmp "tmpdir", *args end + def with_root_gemspec + if ruby_core? + spec = Gem::Specification.load(gemspec.to_s) + spec.bindir = "libexec" + File.open(root.join("bundler.gemspec").to_s, "w") {|f| f.write spec.to_ruby } + yield(root.join("bundler.gemspec")) + FileUtils.rm(root.join("bundler.gemspec")) + else + yield(gemspec) + end + end + def ruby_core? # avoid to wornings @ruby_core ||= nil |