mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 21:44:30 +02:00

(https://github.com/ruby/irb/pull/877)
* Make help command display help for individual commands
Usage: `help [command]`
If the command is not specified, it will display a list of all available commands.
If the command is specified, it will display the banner OR description of the command.
If the command is not found, it will display a message saying that the command is not found.
* Rename test/irb/cmd to test/irb/command
* Add banner to edit and ls commands
* Promote help command in the help message
1. Make `show_cmds` an alias of `help` so it's not displayed in the help message
2. Update description of the help command to reflect `help <command>` syntax
* Rename banner to help_message
43a2c99f3f
63 lines
1.4 KiB
Ruby
63 lines
1.4 KiB
Ruby
# frozen_string_literal: false
|
|
require 'irb'
|
|
|
|
require_relative "../helper"
|
|
|
|
module TestIRB
|
|
class ForceExitTest < IntegrationTestCase
|
|
def test_forced_exit_finishes_process_immediately
|
|
write_ruby <<~'ruby'
|
|
puts "First line"
|
|
puts "Second line"
|
|
binding.irb
|
|
puts "Third line"
|
|
binding.irb
|
|
puts "Fourth line"
|
|
ruby
|
|
|
|
output = run_ruby_file do
|
|
type "123"
|
|
type "456"
|
|
type "exit!"
|
|
end
|
|
|
|
assert_match(/First line\r\n/, output)
|
|
assert_match(/Second line\r\n/, output)
|
|
assert_match(/irb\(main\):001> 123/, output)
|
|
assert_match(/irb\(main\):002> 456/, output)
|
|
refute_match(/Third line\r\n/, output)
|
|
refute_match(/Fourth line\r\n/, output)
|
|
end
|
|
|
|
def test_forced_exit_in_nested_sessions
|
|
write_ruby <<~'ruby'
|
|
def foo
|
|
binding.irb
|
|
end
|
|
|
|
binding.irb
|
|
binding.irb
|
|
ruby
|
|
|
|
output = run_ruby_file do
|
|
type "123"
|
|
type "foo"
|
|
type "exit!"
|
|
end
|
|
|
|
assert_match(/irb\(main\):001> 123/, output)
|
|
end
|
|
|
|
def test_forced_exit_out_of_irb_session
|
|
write_ruby <<~'ruby'
|
|
at_exit { puts 'un' + 'reachable' }
|
|
binding.irb
|
|
exit! # this will call exit! method overrided by command
|
|
ruby
|
|
output = run_ruby_file do
|
|
type "exit"
|
|
end
|
|
assert_not_include(output, 'unreachable')
|
|
end
|
|
end
|
|
end
|