summaryrefslogtreecommitdiff
path: root/test/irb
diff options
context:
space:
mode:
authorStan Lo <stan.lo@shopify.com>2022-12-08 21:46:51 +0000
committergit <svn-admin@ruby-lang.org>2022-12-08 21:46:55 +0000
commitc9076d546aae9dbcb7da404aada7ce8d23e2273b (patch)
treeed88cf7de6f4a8e762c3bc43858cdb11c0bfdbaf /test/irb
parent12b7c129bf8ed3a113e2cc73f817868507504268 (diff)
downloadruby-c9076d546aae9dbcb7da404aada7ce8d23e2273b.tar.gz
[ruby/irb] Add show_doc as an alias to the help command
(https://github.com/ruby/irb/pull/475) In the long-term, we want to align with `Pry`, `byebug` and `debug` to use the `help` command to list all commands, which is what `show_cmds` currently does. And `show_doc` will be the command to look up Ruby APIs. By aliasing `show_doc` to the current `help` now, users will have time to get use to it.
Diffstat (limited to 'test/irb')
-rw-r--r--test/irb/test_cmd.rb20
1 files changed, 11 insertions, 9 deletions
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" }