diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-08-21 20:17:11 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-09-05 18:42:26 +0900 |
commit | fea91d69a3b4aebd5e69058f9ec51adf2896cdfd (patch) | |
tree | 7cab5651128ef5f9b311747711c0e454ead7d610 /test | |
parent | f9f6a3d793186bd4b8897f775dcdcc9719361c11 (diff) | |
download | bundler-fea91d69a3b4aebd5e69058f9ec51adf2896cdfd.tar.gz |
[rubygems/rubygems] Don't fail when `uninstall --all` with default gem
Instead, display an informative message saying that uninstallation of
specific versions is being skipped because of being default gems.
https://github.com/rubygems/rubygems/commit/b44845aa1d
Diffstat (limited to 'test')
-rw-r--r-- | test/rubygems/test_gem_commands_uninstall_command.rb | 45 | ||||
-rw-r--r-- | test/rubygems/test_gem_uninstaller.rb | 8 |
2 files changed, 49 insertions, 4 deletions
diff --git a/test/rubygems/test_gem_commands_uninstall_command.rb b/test/rubygems/test_gem_commands_uninstall_command.rb index 4ac06977e3..927a241203 100644 --- a/test/rubygems/test_gem_commands_uninstall_command.rb +++ b/test/rubygems/test_gem_commands_uninstall_command.rb @@ -41,6 +41,51 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase Gem::Specification.all_names.sort end + def test_execute_all_named_default_single + z_1 = new_default_spec 'z', '1' + install_default_gems z_1 + + assert_includes Gem::Specification.all_names, 'z-1' + + @cmd.options[:all] = true + @cmd.options[:args] = %w[z] + + use_ui @ui do + @cmd.execute + end + + assert_equal %w[z-1], Gem::Specification.all_names.sort + + output = @ui.output.split "\n" + + assert_equal 'Gem z-1 cannot be uninstalled because it is a default gem', output.shift + end + + def test_execute_all_named_default_multiple + z_1 = new_default_spec 'z', '1' + install_default_gems z_1 + + z_2, = util_gem 'z', 2 + install_gem z_2 + + assert_includes Gem::Specification.all_names, 'z-1' + assert_includes Gem::Specification.all_names, 'z-2' + + @cmd.options[:all] = true + @cmd.options[:args] = %w[z] + + use_ui @ui do + @cmd.execute + end + + assert_equal %w[z-1], Gem::Specification.all_names.sort + + output = @ui.output.split "\n" + + assert_equal 'Gem z-1 cannot be uninstalled because it is a default gem', output.shift + assert_equal 'Successfully uninstalled z-2', output.shift + end + def test_execute_dependency_order initial_install diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb index 9dfef7cfda..bf5ef5b4a2 100644 --- a/test/rubygems/test_gem_uninstaller.rb +++ b/test/rubygems/test_gem_uninstaller.rb @@ -221,13 +221,13 @@ class TestGemUninstaller < Gem::InstallerTestCase uninstaller = Gem::Uninstaller.new spec.name, :executables => true - e = assert_raises Gem::InstallError do + use_ui @ui do uninstaller.uninstall end - assert_equal 'gem "default" cannot be uninstalled ' + - 'because it is a default gem', - e.message + lines = @ui.output.split("\n") + + assert_equal 'Gem default-2 cannot be uninstalled because it is a default gem', lines.shift end def test_uninstall_default_gem_with_same_version |