aboutsummaryrefslogtreecommitdiffstats
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.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/rubygems/test_gem_commands_open_command.rb b/test/rubygems/test_gem_commands_open_command.rb
index e6cbb43355..3ec38972e6 100644
--- a/test/rubygems/test_gem_commands_open_command.rb
+++ b/test/rubygems/test_gem_commands_open_command.rb
@@ -10,9 +10,10 @@ class TestGemCommandsOpenCommand < Gem::TestCase
@cmd = Gem::Commands::OpenCommand.new
end
- def gem name
+ def gem(name, version = "1.0")
spec = quick_gem name do |gem|
gem.files = %W[lib/#{name}.rb Rakefile]
+ gem.version = version
end
write_file File.join(*%W[gems #{spec.full_name} lib #{name}.rb])
write_file File.join(*%W[gems #{spec.full_name} Rakefile])
@@ -37,6 +38,22 @@ class TestGemCommandsOpenCommand < Gem::TestCase
assert_equal "", @ui.error
end
+ def test_wrong_version
+ @cmd.options[:version] = "4.0"
+ @cmd.options[:args] = %w[foo]
+
+ gem "foo", "5.0"
+
+ assert_raises Gem::MockGemUi::TermError do
+ use_ui @ui do
+ @cmd.execute
+ end
+ end
+
+ assert_match %r|Unable to find gem 'foo'|, @ui.output
+ assert_equal "", @ui.error
+ end
+
def test_execute_bad_gem
@cmd.options[:args] = %w[foo]