summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_commands_open_command.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rubygems/test_gem_commands_open_command.rb')
-rw-r--r--test/rubygems/test_gem_commands_open_command.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/test/rubygems/test_gem_commands_open_command.rb b/test/rubygems/test_gem_commands_open_command.rb
index f970ca12d6..d9e518048c 100644
--- a/test/rubygems/test_gem_commands_open_command.rb
+++ b/test/rubygems/test_gem_commands_open_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "helper"
require "rubygems/commands/open_command"
@@ -21,20 +22,23 @@ class TestGemCommandsOpenCommand < Gem::TestCase
def test_execute
@cmd.options[:args] = %w[foo]
- @cmd.options[:editor] = "#{ruby_with_rubygems_in_load_path} -eexit --"
+ @cmd.options[:editor] = (ruby_with_rubygems_in_load_path + ["-e", "puts(ARGV,Dir.pwd)", "--"]).join(" ")
gem "foo", "1.0.0"
spec = gem "foo", "1.0.1"
assert_nothing_raised Gem::MockGemUi::TermError do
- Dir.stub(:chdir, spec.full_gem_path) do
+ stdout, stderr = capture_subprocess_io do
use_ui @ui do
@cmd.execute
end
end
+ assert_equal [spec.full_gem_path, spec.full_gem_path], stdout.split("\n")
+ assert_equal "", stderr
end
assert_equal "", @ui.error
+ assert_equal "", @ui.output
end
def test_wrong_version
@@ -49,7 +53,7 @@ class TestGemCommandsOpenCommand < Gem::TestCase
end
end
- assert_match %r{Unable to find gem 'foo'}, @ui.output
+ assert_match(/Unable to find gem 'foo'/, @ui.output)
assert_equal "", @ui.error
end
@@ -62,7 +66,7 @@ class TestGemCommandsOpenCommand < Gem::TestCase
end
end
- assert_match %r{Unable to find gem 'foo'}, @ui.output
+ assert_match(/Unable to find gem 'foo'/, @ui.output)
assert_equal "", @ui.error
end
@@ -91,7 +95,7 @@ class TestGemCommandsOpenCommand < Gem::TestCase
end
end
- assert_match %r{'foo' is a default gem and can't be opened\.} , @ui.output
+ assert_match(/'foo' is a default gem and can't be opened\./, @ui.output)
assert_equal "", @ui.error
end
end