summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_commands_exec_command.rb
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2023-02-13 18:39:08 -0800
committergit <svn-admin@ruby-lang.org>2023-02-22 08:42:17 +0000
commit2dd96983505285bf58845d1687a9a6d6c0af959b (patch)
tree7ae673c2f046f63a6ca08502433aae1a42f5b1e5 /test/rubygems/test_gem_commands_exec_command.rb
parent47d4f73ee755a0ae7b26eb2e35b820202e008763 (diff)
downloadruby-2dd96983505285bf58845d1687a9a6d6c0af959b.tar.gz
[rubygems/rubygems] Allow gem exec gem
https://github.com/rubygems/rubygems/commit/a767f7b9be
Diffstat (limited to 'test/rubygems/test_gem_commands_exec_command.rb')
-rw-r--r--test/rubygems/test_gem_commands_exec_command.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_commands_exec_command.rb b/test/rubygems/test_gem_commands_exec_command.rb
index 5f988d5b5c..d4f8827808 100644
--- a/test/rubygems/test_gem_commands_exec_command.rb
+++ b/test/rubygems/test_gem_commands_exec_command.rb
@@ -701,4 +701,45 @@ class TestGemCommandsExecCommand < Gem::TestCase
assert_equal %w[b-2], @installed_specs.map(&:original_name)
end
end
+
+ def test_gem_exec_gem_uninstall
+ spec_fetcher do |fetcher|
+ fetcher.download "a", 2 do |s|
+ s.executables = %w[a]
+ s.files = %w[bin/a lib/a.rb]
+ s.add_runtime_dependency "b"
+
+ write_file File.join(*%W[gems #{s.original_name} bin a]) do |f|
+ f << "Gem.ui.say #{s.original_name.dump}"
+ end
+ end
+
+ fetcher.download "b", 2 do |s|
+ s.files = %w[lib/b.rb]
+ end
+ end
+
+ use_ui @ui do
+ invoke "a:2"
+ assert_equal "a-2\n", @ui.output
+
+ invoke "gem", "list", "--local"
+ assert_includes @ui.output, "a (2)\n"
+ assert_includes @ui.output, "b (2)\n"
+
+ invoke "gem", "uninstall", "--verbose", "-x", "a" rescue nil
+ refute_includes @ui.output, "running gem exec with"
+ assert_includes @ui.output, "Successfully uninstalled a-2\n"
+
+ invoke "--verbose", "gem", "uninstall", "b"
+ assert_includes @ui.output, "Successfully uninstalled b-2\n"
+
+ invoke "gem", "list", "--local"
+ assert_empty @ui.error
+ assert_match /\A\s*\** LOCAL GEMS \**\s*\z/m, @ui.output
+
+ invoke "gem", "env", "GEM_HOME"
+ assert_match /#{File::SEPARATOR}gem_exec$/, @ui.output
+ end
+ end
end