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.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_commands_open_command.rb b/test/rubygems/test_gem_commands_open_command.rb
index a96fa6ea23..e73a138204 100644
--- a/test/rubygems/test_gem_commands_open_command.rb
+++ b/test/rubygems/test_gem_commands_open_command.rb
@@ -68,4 +68,33 @@ class TestGemCommandsOpenCommand < Gem::TestCase
assert_equal "", @ui.error
end
+ def test_default_gem
+ @cmd.options[:version] = "1.0"
+ @cmd.options[:args] = %w[foo]
+
+ version = @cmd.options[:version]
+ @cmd.define_singleton_method(:spec_for) do |name|
+ spec = Gem::Specification.find_all_by_name(name, version).first
+
+ spec.define_singleton_method(:default_gem?) do
+ true
+ end
+
+ return spec if spec
+
+ say "Unable to find gem '#{name}'"
+ end
+
+ gem("foo", "1.0")
+
+ assert_raises Gem::MockGemUi::TermError do
+ use_ui @ui do
+ @cmd.execute
+ end
+ end
+
+ assert_match %r|'foo' is a default gem and can't be opened\.| , @ui.output
+ assert_equal "", @ui.error
+ end
+
end