From d22130922e7842226d38d59680e4bbb48a28a5f0 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 1 Jun 2011 03:45:05 +0000 Subject: Import rubygems 1.8.5 (released @ 137c80f) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rubygems/test_gem_uninstaller.rb | 66 ++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 25 deletions(-) (limited to 'test/rubygems/test_gem_uninstaller.rb') diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb index 0c08f42d01..93a6f6535b 100644 --- a/test/rubygems/test_gem_uninstaller.rb +++ b/test/rubygems/test_gem_uninstaller.rb @@ -14,26 +14,15 @@ class TestGemUninstaller < Gem::InstallerTestCase @user_spec.executables = ["executable"] - # HACK util_make_exec - user_bin_dir = File.join Gem.user_dir, 'gems', @user_spec.full_name, 'bin' - FileUtils.mkdir_p user_bin_dir - exec_path = File.join user_bin_dir, "executable" - open exec_path, 'w' do |f| - f.puts "#!/usr/bin/ruby" - end - - user_bin_dir = File.join Gem.user_dir, 'bin' - FileUtils.mkdir_p user_bin_dir - exec_path = File.join user_bin_dir, "executable" - open exec_path, 'w' do |f| - f.puts "#!/usr/bin/ruby" - end - build_rake_in do use_ui ui do @installer.install @user_installer.install - Gem::Uninstaller.new(@user_spec.name, :executables => false).uninstall + + Gem.use_paths @gemhome, Gem.user_dir + + @spec = Gem::Specification.find_by_name 'a' + @user_spec = Gem::Specification.find_by_name 'b' end end end @@ -44,6 +33,18 @@ class TestGemUninstaller < Gem::InstallerTestCase assert_match %r|/foo/bar$|, uninstaller.instance_variable_get(:@gem_home) end + def test_remove_all + uninstaller = Gem::Uninstaller.new nil + + ui = Gem::MockGemUi.new "y\n" + + use_ui ui do + uninstaller.remove_all [@spec] + end + + refute_path_exists @spec.gem_dir + end + def test_remove_executables_force_keep uninstaller = Gem::Uninstaller.new nil, :executables => false @@ -114,14 +115,13 @@ class TestGemUninstaller < Gem::InstallerTestCase end exec_path = File.join Gem.user_dir, 'bin', 'executable' - assert_equal false, File.exist?(exec_path), 'removed exec from bin dir' + refute File.exist?(exec_path), 'removed exec from bin dir' assert_equal "Removing executable\n", @ui.output ensure Gem::Installer.exec_format = nil end - def test_path_ok_eh uninstaller = Gem::Uninstaller.new nil @@ -131,7 +131,7 @@ class TestGemUninstaller < Gem::InstallerTestCase def test_path_ok_eh_legacy uninstaller = Gem::Uninstaller.new nil - @spec.loaded_from.gsub! @spec.full_name, '\&-legacy' + @spec.loaded_from = @spec.loaded_from.gsub @spec.full_name, '\&-legacy' @spec.platform = 'legacy' assert_equal true, uninstaller.path_ok?(@gemhome, @spec) @@ -190,26 +190,42 @@ class TestGemUninstaller < Gem::InstallerTestCase end def test_uninstall_user - uninstaller = Gem::Uninstaller.new @user_spec.name, :executables => true, - :user_install => true + @user_spec = Gem::Specification.find_by_name 'b' + + uninstaller = Gem::Uninstaller.new(@user_spec.name, + :executables => true, + :user_install => true) gem_dir = File.join Gem.user_dir, 'gems', @user_spec.full_name Gem.pre_uninstall do - assert File.exist?(gem_dir), 'gem_dir should exist' + assert_path_exists gem_dir end Gem.post_uninstall do - refute File.exist?(gem_dir), 'gem_dir should not exist' + refute_path_exists gem_dir end uninstaller.uninstall - refute File.exist?(gem_dir) + refute_path_exists gem_dir assert_same uninstaller, @pre_uninstall_hook_arg assert_same uninstaller, @post_uninstall_hook_arg end -end + def test_uninstall_selection_greater_than_one + util_make_gems + + list = Gem::Specification.find_all_by_name('a') + + uninstaller = Gem::Uninstaller.new('a') + + use_ui Gem::MockGemUi.new("2\n") do + uninstaller.uninstall + end + updated_list = Gem::Specification.find_all_by_name('a') + assert_equal list.length - 1, updated_list.length + end +end -- cgit v1.2.3