ruby/test/irb/command/test_force_exit.rb
Stan Lo 07c774e85c [ruby/irb] Revamp help command
(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
2024-02-18 18:21:08 +00:00

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