summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_uninstaller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rubygems/test_gem_uninstaller.rb')
-rw-r--r--test/rubygems/test_gem_uninstaller.rb23
1 files changed, 21 insertions, 2 deletions
diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb
index 126011be99..7440ca0191 100644
--- a/test/rubygems/test_gem_uninstaller.rb
+++ b/test/rubygems/test_gem_uninstaller.rb
@@ -22,9 +22,10 @@ class TestGemUninstaller < Gem::InstallerTestCase
end
def test_initialize_expand_path
- uninstaller = Gem::Uninstaller.new nil, :install_dir => '/foo//bar'
+ FileUtils.mkdir_p 'foo/bar'
+ uninstaller = Gem::Uninstaller.new nil, :install_dir => 'foo//bar'
- assert_match %r|/foo/bar$|, uninstaller.instance_variable_get(:@gem_home)
+ assert_match %r|foo/bar$|, uninstaller.instance_variable_get(:@gem_home)
end
def test_ask_if_ok
@@ -133,6 +134,7 @@ class TestGemUninstaller < Gem::InstallerTestCase
end
def test_remove_not_in_home
+ Dir.mkdir "#{@gemhome}2"
uninstaller = Gem::Uninstaller.new nil, :install_dir => "#{@gemhome}2"
e = assert_raises Gem::GemNotInHomeException do
@@ -149,6 +151,22 @@ class TestGemUninstaller < Gem::InstallerTestCase
assert_path_exists @spec.gem_dir
end
+ def test_remove_symlinked_gem_home
+ Dir.mktmpdir("gem_home") do |dir|
+ symlinked_gem_home = "#{dir}/#{File.basename(@gemhome)}"
+
+ FileUtils.ln_s(@gemhome, dir)
+
+ uninstaller = Gem::Uninstaller.new nil, :install_dir => symlinked_gem_home
+
+ use_ui ui do
+ uninstaller.remove @spec
+ end
+
+ refute_path_exists @spec.gem_dir
+ end
+ end
+
def test_path_ok_eh
uninstaller = Gem::Uninstaller.new nil
@@ -313,6 +331,7 @@ create_makefile '#{@spec.name}'
end
def test_uninstall_wrong_repo
+ Dir.mkdir "#{@gemhome}2"
Gem.use_paths "#{@gemhome}2", [@gemhome]
uninstaller = Gem::Uninstaller.new @spec.name, :executables => true