aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-07-28 12:27:56 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-08-02 15:04:28 -0500
commit3e25cb850e922e58ab551abeadb42f413c2ebb52 (patch)
treebb6dc018041c95bc5c2925786c74ff74e76cde96
parent8b2be1b2a373aed884ee8f0b2f3dc0e792729340 (diff)
downloadbundler-3e25cb850e922e58ab551abeadb42f413c2ebb52.tar.gz
Move the gem_command helper to existing execution infrastructure
-rw-r--r--spec/quality_spec.rb12
-rw-r--r--spec/support/builders.rb2
-rw-r--r--spec/support/helpers.rb11
-rw-r--r--spec/support/rubygems_ext.rb9
4 files changed, 18 insertions, 16 deletions
diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb
index 41f7d584..778bfe50 100644
--- a/spec/quality_spec.rb
+++ b/spec/quality_spec.rb
@@ -184,11 +184,13 @@ describe "The library itself" do
it "can still be built" do
Dir.chdir(root) do
- `gem build bundler.gemspec`
- expect($?).to eq(0)
-
- # clean up the .gem generated
- system("rm bundler-#{Bundler::VERSION}.gem")
+ begin
+ gem_command! :build, "bundler.gemspec"
+ expect(err).to be_empty, "bundler should build as a gem without warnings, but\n#{err}"
+ ensure
+ # clean up the .gem generated
+ FileUtils.rm("bundler-#{Bundler::VERSION}.gem")
+ end
end
end
diff --git a/spec/support/builders.rb b/spec/support/builders.rb
index 058b7f10..71e76a8c 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -376,7 +376,7 @@ module Spec
@_build_repo = File.basename(path)
yield
with_gem_path_as Path.base_system_gems do
- Dir.chdir(path) { gem_command :generate_index }
+ Dir.chdir(path) { gem_command! :generate_index }
end
ensure
@_build_path = nil
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index d00e8a38..1ff9bc96 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -159,6 +159,15 @@ module Spec
ENV["RUBYOPT"] = old
end
+ def gem_command(command, args = "", options = {})
+ if command == :exec && !options[:no_quote]
+ args = args.gsub(/(?=")/, "\\")
+ args = %("#{args}")
+ end
+ sys_exec("#{Gem.ruby} -rubygems -S gem --backtrace #{command} #{args}", options[:expect_err])
+ end
+ bang :gem_command
+
def sys_exec(cmd, expect_err = false)
Open3.popen3(cmd.to_s) do |stdin, stdout, stderr, wait_thr|
yield stdin, stdout, wait_thr if block_given?
@@ -236,7 +245,7 @@ module Spec
raise "OMG `#{path}` does not exist!" unless File.exist?(path)
- gem_command :install, "--no-rdoc --no-ri --ignore-dependencies #{path}"
+ gem_command! :install, "--no-rdoc --no-ri --ignore-dependencies #{path}"
end
end
diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb
index e4365031..4ddbc331 100644
--- a/spec/support/rubygems_ext.rb
+++ b/spec/support/rubygems_ext.rb
@@ -50,14 +50,5 @@ module Spec
cmd += " --version '#{version}'" if version
system(cmd) || raise("Installing gem #{name} for the tests to use failed!")
end
-
- def gem_command(command, args = "", options = {})
- if command == :exec && !options[:no_quote]
- args = args.gsub(/(?=")/, "\\")
- args = %("#{args}")
- end
- lib = File.join(File.dirname(__FILE__), "..", "..", "lib")
- `#{Gem.ruby} -I#{lib} -rubygems -S gem --backtrace #{command} #{args}`.strip
- end
end
end