diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-09 21:38:59 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-09 21:38:59 +0000 |
commit | 31c94ffeb5f09d09ac2c86fc9e6614e38251a43d (patch) | |
tree | 10e44506238c7af3d7c9d822111996731726e38d /test/rubygems/test_gem_uninstaller.rb | |
parent | a6afbaeb3be396c0fdea3b9077d9256c59edcfca (diff) | |
download | ruby-31c94ffeb5f09d09ac2c86fc9e6614e38251a43d.tar.gz |
Update to RubyGems 1.3.4 r2223
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_uninstaller.rb')
-rw-r--r-- | test/rubygems/test_gem_uninstaller.rb | 68 |
1 files changed, 64 insertions, 4 deletions
diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb index bb90f5cc5f..2b026e9c4c 100644 --- a/test/rubygems/test_gem_uninstaller.rb +++ b/test/rubygems/test_gem_uninstaller.rb @@ -10,9 +10,28 @@ class TestGemUninstaller < GemInstallerTestCase ui = MockGemUi.new util_setup_gem ui + @user_spec.executables = ["my_exec"] + + # 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, "my_exec" + File.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, "my_exec" + File.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 end end end @@ -47,10 +66,23 @@ class TestGemUninstaller < GemInstallerTestCase assert_equal false, File.exist?(File.join(@gemhome, 'bin', 'executable')) end + def test_remove_executables_user + uninstaller = Gem::Uninstaller.new nil, :executables => true + + use_ui @ui do + uninstaller.remove_executables @user_spec + end + + exec_path = File.join Gem.user_dir, 'bin', 'my_exec' + assert_equal false, File.exist?(exec_path), 'removed exec from bin dir' + + assert_equal "Removing my_exec\n", @ui.output + end + def test_path_ok_eh uninstaller = Gem::Uninstaller.new nil - assert_equal true, uninstaller.path_ok?(@spec) + assert_equal true, uninstaller.path_ok?(@gemhome, @spec) end def test_path_ok_eh_legacy @@ -59,7 +91,13 @@ class TestGemUninstaller < GemInstallerTestCase @spec.loaded_from.gsub! @spec.full_name, '\&-legacy' @spec.platform = 'legacy' - assert_equal true, uninstaller.path_ok?(@spec) + assert_equal true, uninstaller.path_ok?(@gemhome, @spec) + end + + def test_path_ok_eh_user + uninstaller = Gem::Uninstaller.new nil + + assert_equal true, uninstaller.path_ok?(Gem.user_dir, @user_spec) end def test_uninstall @@ -72,12 +110,34 @@ class TestGemUninstaller < GemInstallerTestCase end Gem.post_uninstall do - assert !File.exist?(gem_dir), 'gem_dir should not exist' + refute File.exist?(gem_dir), 'gem_dir should not exist' + end + + uninstaller.uninstall + + refute File.exist?(gem_dir) + + assert_same uninstaller, @pre_uninstall_hook_arg + assert_same uninstaller, @post_uninstall_hook_arg + end + + def test_uninstall_user + 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' + end + + Gem.post_uninstall do + refute File.exist?(gem_dir), 'gem_dir should not exist' end uninstaller.uninstall - assert !File.exist?(gem_dir) + refute File.exist?(gem_dir) assert_same uninstaller, @pre_uninstall_hook_arg assert_same uninstaller, @post_uninstall_hook_arg |