From 5dbc6583c93621a7e992163bd27991bd3d3d9378 Mon Sep 17 00:00:00 2001 From: hsbt Date: Wed, 28 Nov 2018 03:08:14 +0000 Subject: Merge rubygems upstream from https://github.com/rubygems/rubygems/commit/2c499655f29070c809dfea9f5fda6fac6850e62e https://github.com/rubygems/rubygems/pull/2493 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- .../test_gem_commands_uninstall_command.rb | 59 ++++++++++++++++++++-- 1 file changed, 54 insertions(+), 5 deletions(-) (limited to 'test/rubygems/test_gem_commands_uninstall_command.rb') diff --git a/test/rubygems/test_gem_commands_uninstall_command.rb b/test/rubygems/test_gem_commands_uninstall_command.rb index f62f4277ed..407d2451a6 100644 --- a/test/rubygems/test_gem_commands_uninstall_command.rb +++ b/test/rubygems/test_gem_commands_uninstall_command.rb @@ -151,12 +151,14 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase assert_match(/Successfully uninstalled/, output) end - def test_execute_with_force_leaves_executable + def test_execute_with_version_leaves_non_matching_versions ui = Gem::MockGemUi.new util_make_gems util_setup_gem ui + assert_equal 3, Gem::Specification.find_all_by_name('a').length + @cmd.options[:version] = '1' @cmd.options[:force] = true @cmd.options[:args] = ['a'] @@ -165,17 +167,43 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase @cmd.execute end - assert !Gem::Specification.all_names.include?('a') + assert_equal 2, Gem::Specification.find_all_by_name('a').length + assert File.exist? File.join(@gemhome, 'bin', 'executable') end - def test_execute_with_force_uninstalls_all_versions + def test_execute_with_version_specified_as_colon ui = Gem::MockGemUi.new "y\n" util_make_gems util_setup_gem ui - assert Gem::Specification.find_all_by_name('a').length > 1 + assert_equal 3, Gem::Specification.find_all_by_name('a').length + + @cmd.options[:force] = true + @cmd.options[:args] = ['a:1'] + + use_ui ui do + @cmd.execute + end + + assert_equal 2, Gem::Specification.find_all_by_name('a').length + + assert File.exist? File.join(@gemhome, 'bin', 'executable') + end + + def test_execute_with_force_and_without_version_uninstalls_everything + ui = Gem::MockGemUi.new "y\n" + + a_1, = util_gem 'a', 1 + install_gem a_1 + + a_3a, = util_gem 'a', '3.a' + install_gem a_3a + + util_setup_gem ui + + assert_equal 3, Gem::Specification.find_all_by_name('a').length @cmd.options[:force] = true @cmd.options[:args] = ['a'] @@ -184,7 +212,9 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase @cmd.execute end - refute_includes Gem::Specification.all_names, 'a' + assert_empty Gem::Specification.find_all_by_name('a') + assert_match "Removing executable", ui.output + refute File.exist? @executable end def test_execute_with_force_ignores_dependencies @@ -261,6 +291,25 @@ WARNING: Use your OS package manager to uninstall vendor gems assert_match expected, @ui.error 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 + + msg = "ERROR: Can't use --version with multiple gems. You can specify multiple gems with" \ + " version requirements using `gem uninstall 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`" + + assert_empty @ui.output + assert_equal msg, @ui.error.lines.last.chomp + end + def test_handle_options_vendor_missing orig_vendordir = RbConfig::CONFIG['vendordir'] RbConfig::CONFIG.delete 'vendordir' -- cgit v1.2.3