Permalink
Browse files

+ Raise an error on install with multiple gems and --version

  • Loading branch information...
1 parent ab86ce8 commit 62653cb808b7020eec98151445f4caf0812b01ce @zenspider zenspider committed Jun 29, 2012
Showing with 26 additions and 0 deletions.
  1. +6 −0 lib/rubygems/commands/install_command.rb
  2. +20 −0 test/rubygems/test_gem_commands_install_command.rb
@@ -153,6 +153,12 @@ def execute
exit_code = 0
+ if options[:version] != Gem::Requirement.default &&
+ get_all_gem_names.size > 1 then
+ alert_error "Can't use --version w/ multiple gems. Use name:ver instead."
+ terminate_interaction 1
+ end
+
get_all_gem_names_and_versions.each do |gem_name, gem_version|
gem_version ||= options[:version]
@@ -443,6 +443,26 @@ def test_execute_two
assert out.empty?, out.inspect
end
+ def test_execute_two_version
+ @cmd.options[:args] = %w[a b]
+ @cmd.options[:version] = Gem::Requirement.new("> 1")
+
+ use_ui @ui do
+ e = assert_raises Gem::MockGemUi::TermError do
+ @cmd.execute
+ end
+
+ assert_equal 1, e.exit_code
+ end
+
+ assert_empty @cmd.installed_specs
+
+ msg = "ERROR: Can't use --version w/ multiple gems. Use name:ver instead."
+
+ assert_empty @ui.output
+ assert_equal msg, @ui.error.chomp
+ end
+
def test_execute_conservative
util_setup_fake_fetcher
util_setup_spec_fetcher

0 comments on commit 62653cb

Please sign in to comment.