diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-19 07:19:10 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-19 07:19:10 +0000 |
commit | eddc0685f224a6de2f5a6bdaab7f87562192ba7f (patch) | |
tree | 54f3427a70f2cc21e9dbbb6c3ad9ed500ea96865 /test/rubygems/test_gem_uninstaller.rb | |
parent | 1b2be1f8ca5286a75d9401f96eaec89317353e3e (diff) |
* lib/rubygems/commands/query_command.rb: Refactored to improve
maintainability.
* test/rubygems/test_gem_commands_query_command.rb: Note default gems
in gem list details.
* lib/rubygems/uninstaller.rb: Detect all gems for uninstallation.
This allows duplicate installs of default gems to be removed.
* lib/rubygems/specification.rb: Allow use of ::each_spec.
* lib/rubygems/test_case.rb: Added install_default_gems.
* test/rubygems/test_gem_commands_uninstall_command.rb: Moved test
down to the uninstaller tests.
* test/rubygems/test_gem_uninstaller.rb: Test for uninstallation of
default gems and duplicate default gems.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_uninstaller.rb')
-rw-r--r-- | test/rubygems/test_gem_uninstaller.rb | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb index f6fe4a9a4f..948318a5e3 100644 --- a/test/rubygems/test_gem_uninstaller.rb +++ b/test/rubygems/test_gem_uninstaller.rb @@ -172,6 +172,38 @@ class TestGemUninstaller < Gem::InstallerTestCase assert_same uninstaller, @post_uninstall_hook_arg end + def test_uninstall_default_gem + spec = new_default_spec 'default', '2' + + install_default_gems spec + + uninstaller = Gem::Uninstaller.new spec.name, :executables => true + + e = assert_raises Gem::InstallError do + uninstaller.uninstall + end + + assert_equal 'gem "default" cannot be uninstalled ' + + 'because it is a default gem', + e.message + end + + def test_uninstall_default_gem_with_same_version + default_spec = new_default_spec 'default', '2' + install_default_gems default_spec + + spec = new_spec 'default', '2' + install_gem spec + + Gem::Specification.reset + + uninstaller = Gem::Uninstaller.new spec.name, :executables => true + + uninstaller.uninstall + + refute_path_exists spec.gem_dir + end + def test_uninstall_nonexistent uninstaller = Gem::Uninstaller.new 'bogus', :executables => true @@ -265,8 +297,8 @@ class TestGemUninstaller < Gem::InstallerTestCase end def test_uninstall_prompts_about_broken_deps - util_gem 'r', '1', 'q' => '= 1' - util_gem 'q', '1' + quick_gem 'r', '1' do |s| s.add_dependency 'q', '= 1' end + quick_gem 'q', '1' un = Gem::Uninstaller.new('q') ui = Gem::MockGemUi.new("y\n") @@ -287,10 +319,10 @@ class TestGemUninstaller < Gem::InstallerTestCase end def test_uninstall_only_lists_unsatified_deps - util_gem 'r', '1', 'q' => '~> 1.0' - util_gem 'x', '1', 'q' => '= 1.0' - util_gem 'q', '1.0' - util_gem 'q', '1.1' + quick_gem 'r', '1' do |s| s.add_dependency 'q', '~> 1.0' end + quick_gem 'x', '1' do |s| s.add_dependency 'q', '= 1.0' end + quick_gem 'q', '1.0' + quick_gem 'q', '1.1' un = Gem::Uninstaller.new('q', :version => "1.0") ui = Gem::MockGemUi.new("y\n") @@ -311,9 +343,9 @@ class TestGemUninstaller < Gem::InstallerTestCase end def test_uninstall_doesnt_prompt_when_other_gem_satifies_requirement - util_gem 'r', '1', 'q' => '~> 1.0' - util_gem 'q', '1.0' - util_gem 'q', '1.1' + quick_gem 'r', '1' do |s| s.add_dependency 'q', '~> 1.0' end + quick_gem 'q', '1.0' + quick_gem 'q', '1.1' un = Gem::Uninstaller.new('q', :version => "1.0") ui = Gem::MockGemUi.new("y\n") @@ -328,11 +360,8 @@ class TestGemUninstaller < Gem::InstallerTestCase end def test_uninstall_doesnt_prompt_when_removing_a_dev_dep - util_gem('r', '1') do |s| - s.add_development_dependency "q", "= 1.0" - end - - util_gem 'q', '1.0' + quick_gem 'r', '1' do |s| s.add_development_dependency 'q', '= 1.0' end + quick_gem 'q', '1.0' un = Gem::Uninstaller.new('q', :version => "1.0") ui = Gem::MockGemUi.new("y\n") @@ -348,11 +377,11 @@ class TestGemUninstaller < Gem::InstallerTestCase def test_uninstall_prompt_includes_dep_type - util_gem 'r', '1' do |s| + quick_gem 'r', '1' do |s| s.add_development_dependency 'q', '= 1' end - util_gem 'q', '1' + quick_gem 'q', '1' un = Gem::Uninstaller.new('q', :check_dev => true) ui = Gem::MockGemUi.new("y\n") |