Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 62653cb808b7020eec98151445f4caf0812b01ce 1 parent ab86ce8
@zenspider zenspider authored
View
6 lib/rubygems/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]
View
20 test/rubygems/test_gem_commands_install_command.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.