summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2024-09-26 12:58:10 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2024-10-02 14:34:54 +0900
commit8e73609c7b4c7fdc35e47cefd8f696777c0da5e6 (patch)
treed06cbf663f638db506d005110e5b2768a0779995 /test
parent63f31a9ed5e668b609ca5f46510e30e8b20739d0 (diff)
[rubygems/rubygems] Fix weirdness of "interrupt" test command
https://github.com/rubygems/rubygems/commit/0a75590ac9
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/rubygems/commands/interrupt_command.rb11
-rw-r--r--test/rubygems/rubygems_plugin.rb19
-rw-r--r--test/rubygems/test_gem.rb11
-rw-r--r--test/rubygems/test_gem_commands_help_command.rb2
4 files changed, 11 insertions, 32 deletions
diff --git a/test/rubygems/rubygems/commands/interrupt_command.rb b/test/rubygems/rubygems/commands/interrupt_command.rb
new file mode 100644
index 0000000000..88d2ef22e7
--- /dev/null
+++ b/test/rubygems/rubygems/commands/interrupt_command.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class Gem::Commands::InterruptCommand < Gem::Command
+ def initialize
+ super("interrupt", "Raises an Interrupt Exception", {})
+ end
+
+ def execute
+ raise Interrupt, "Interrupt exception"
+ end
+end
diff --git a/test/rubygems/rubygems_plugin.rb b/test/rubygems/rubygems_plugin.rb
index 949580f904..f9f2a7d911 100644
--- a/test/rubygems/rubygems_plugin.rb
+++ b/test/rubygems/rubygems_plugin.rb
@@ -2,23 +2,4 @@
require "rubygems/command_manager"
-##
-# This is an example of exactly what NOT to do.
-#
-# DO NOT include code like this in your rubygems_plugin.rb
-
-module Gem::Commands
- remove_const(:InterruptCommand) if defined?(InterruptCommand)
-end
-
-class Gem::Commands::InterruptCommand < Gem::Command
- def initialize
- super("interrupt", "Raises an Interrupt Exception", {})
- end
-
- def execute
- raise Interrupt, "Interrupt exception"
- end
-end
-
Gem::CommandManager.instance.register_command :interrupt
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index e8a294d65c..0d048b08b7 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -21,8 +21,6 @@ class TestGem < Gem::TestCase
common_installer_setup
@additional = %w[a b].map {|d| File.join @tempdir, d }
-
- util_remove_interrupt_command
end
def test_self_finish_resolve
@@ -1524,8 +1522,6 @@ class TestGem < Gem::TestCase
nil
end
- util_remove_interrupt_command
-
# Should attempt to cause a StandardError
with_plugin("standarderror") { Gem.load_env_plugins }
begin
@@ -1534,8 +1530,6 @@ class TestGem < Gem::TestCase
nil
end
- util_remove_interrupt_command
-
# Should attempt to cause an Exception
with_plugin("scripterror") { Gem.load_env_plugins }
begin
@@ -1791,11 +1785,6 @@ class TestGem < Gem::TestCase
spec
end
- def util_remove_interrupt_command
- Gem::Commands.send :remove_const, :InterruptCommand if
- Gem::Commands.const_defined? :InterruptCommand
- end
-
def util_cache_dir
File.join Gem.dir, "cache"
end
diff --git a/test/rubygems/test_gem_commands_help_command.rb b/test/rubygems/test_gem_commands_help_command.rb
index 359da0a6d0..01ab4aab2f 100644
--- a/test/rubygems/test_gem_commands_help_command.rb
+++ b/test/rubygems/test_gem_commands_help_command.rb
@@ -11,8 +11,6 @@ class TestGemCommandsHelpCommand < Gem::TestCase
super
@cmd = Gem::Commands::HelpCommand.new
-
- load File.expand_path("rubygems_plugin.rb", __dir__) unless Gem::Commands.const_defined? :InterruptCommand
end
def test_gem_help_bad