Permalink
Browse files

Exit with code 1 if 'gem list' didnt return anything

  • Loading branch information...
1 parent 2cd811d commit 671cbfafe302b515e026fdc74e491ce0af5a6b16 @bmaland committed Jul 30, 2008
Showing with 24 additions and 0 deletions.
  1. +2 −0 lib/rubygems/commands/query_command.rb
  2. +22 −0 test/test_gem_commands_query_command.rb
@@ -128,6 +128,8 @@ def installed?(name, version = Gem::Requirement.default)
end
def output_query_results(spec_tuples)
+ raise Gem::SystemExitException, 1 if spec_tuples.empty?
+
output = []
versions = Hash.new { |h,name| h[name] = [] }
@@ -112,6 +112,28 @@ def test_execute_installed
assert_equal '', @ui.error
end
+ def test_execute_list_nonexistant_name
+ @cmd.handle_options %w[--name adfaf3415 ]
+
+ e = assert_raise Gem::SystemExitException do
+ use_ui @ui do
+ @cmd.execute
+ end
+ end
+
+ expected = <<-EOF
+
+*** LOCAL GEMS ***
+
+ EOF
+
+ assert_equal expected, @ui.output
+
+ assert_equal '', @ui.error
+
+ assert_equal 1, e.exit_code
+ end
+
def test_execute_installed_no_name
@cmd.handle_options %w[--installed]

0 comments on commit 671cbfa

Please sign in to comment.