diff options
Diffstat (limited to 'test/rubygems/test_gem_commands_uninstall_command.rb')
-rw-r--r-- | test/rubygems/test_gem_commands_uninstall_command.rb | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/test/rubygems/test_gem_commands_uninstall_command.rb b/test/rubygems/test_gem_commands_uninstall_command.rb index 083b831c98..e5090c852f 100644 --- a/test/rubygems/test_gem_commands_uninstall_command.rb +++ b/test/rubygems/test_gem_commands_uninstall_command.rb @@ -22,12 +22,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase a_4, = util_gem "a", 4 install_gem a_4, :install_dir => gemhome2 - Gem::Specification.dirs = [@gemhome, gemhome2] - - assert_includes Gem::Specification.all_names, "a-1" - assert_includes Gem::Specification.all_names, "a-4" - assert_includes Gem::Specification.all_names, "b-2" - assert_includes Gem::Specification.all_names, "default-1" + assert_gems_presence "a-1", "a-4", "b-2", "default-1", dirs: [@gemhome, gemhome2] @cmd.options[:all] = true @cmd.options[:args] = %w[a] @@ -346,11 +341,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase a_4, = util_gem "a", 4 install_gem a_4 - Gem::Specification.dirs = [@gemhome, gemhome2] - - assert_includes Gem::Specification.all_names, "a-1" - assert_includes Gem::Specification.all_names, "a-4" - assert_includes Gem::Specification.all_names, "default-1" + assert_gems_presence "a-1", "a-4", "default-1", dirs: [@gemhome, gemhome2] @cmd.options[:all] = true @cmd.options[:args] = [] @@ -371,9 +362,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase a_4, = util_gem "a", 4 install_gem a_4 , :install_dir => gemhome2 - Gem::Specification.dirs = [@gemhome, gemhome2] - - assert_includes Gem::Specification.all_names, "a-4" + assert_gems_presence "a-4", dirs: [@gemhome, gemhome2] @cmd.options[:args] = ["a:4"] @@ -386,6 +375,26 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase assert_includes e.message, "a is not installed in GEM_HOME" end + def test_execute_outside_gem_home_when_install_dir_given + gemhome2 = "#{@gemhome}2" + + a_4, = util_gem "a", 4 + install_gem a_4 , :install_dir => gemhome2 + + assert_gems_presence "a-4", dirs: [@gemhome, gemhome2] + + Gem::Specification.dirs = [@gemhome] + + @cmd.options[:install_dir] = gemhome2 + @cmd.options[:args] = ["a:4"] + + @cmd.execute + + Gem::Specification.dirs = [gemhome2] + + refute_includes Gem::Specification.all_names.sort, "a-4" + end + def test_handle_options @cmd.handle_options %w[] @@ -501,4 +510,12 @@ WARNING: Use your OS package manager to uninstall vendor gems end end end + + def assert_gems_presence(*gems, dirs:) + Gem::Specification.dirs = dirs + + gems.each do |full_name| + assert_includes Gem::Specification.all_names, full_name + end + end end |