diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb index 9fa2ce5d86..d0829a06c4 100644 --- a/lib/irb/extend-command.rb +++ b/lib/irb/extend-command.rb @@ -162,6 +162,7 @@ module IRB # :nodoc: [ :irb_help, :Help, "cmd/help", + [:show_doc, NO_OVERRIDE], [:help, NO_OVERRIDE], ], diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb index 31cd786ffe..d4b952490d 100644 --- a/test/irb/test_cmd.rb +++ b/test/irb/test_cmd.rb @@ -376,16 +376,18 @@ module TestIRB assert_match(/Please specify the file name./, out) end - def test_help - out, _ = execute_lines( - "help 'String#gsub'\n", - "\n", - ) + def test_help_and_show_doc + ["help", "show_doc"].each do |cmd| + out, _ = execute_lines( + "#{cmd} 'String#gsub'\n", + "\n", + ) - # the former is what we'd get without document content installed, like on CI - # the latter is what we may get locally - possible_rdoc_output = [/Nothing known about String#gsub/, /Returns a copy of self with all occurrences of the given pattern/] - assert(possible_rdoc_output.any? { |output| output.match?(out) }, "Expect the help command to match one of the possible outputs") + # the former is what we'd get without document content installed, like on CI + # the latter is what we may get locally + possible_rdoc_output = [/Nothing known about String#gsub/, /Returns a copy of self with all occurrences of the given pattern/] + assert(possible_rdoc_output.any? { |output| output.match?(out) }, "Expect the `#{cmd}` command to match one of the possible outputs") + end ensure # this is the only way to reset the redefined method without coupling the test with its implementation EnvUtil.suppress_warning { load "irb/cmd/help.rb" }