| 1 |
|
| 2 |
require 'irb' |
| 3 |
|
| 4 |
require_relative "../helper" |
| 5 |
|
| 6 |
module TestIRB |
| 7 |
class ForceExitTest < IntegrationTestCase |
| 8 |
def test_forced_exit_finishes_process_immediately |
| 9 |
write_ruby <<~'ruby' |
| 10 |
puts "First line" |
| 11 |
puts "Second line" |
| 12 |
binding.irb |
| 13 |
puts "Third line" |
| 14 |
binding.irb |
| 15 |
puts "Fourth line" |
| 16 |
ruby |
| 17 |
|
| 18 |
output = run_ruby_file do |
| 19 |
type "123" |
| 20 |
type "456" |
| 21 |
type "exit!" |
| 22 |
end |
| 23 |
|
| 24 |
assert_match(/First line\r\n/, output) |
| 25 |
assert_match(/Second line\r\n/, output) |
| 26 |
assert_match(/irb\(main\):001> 123/, output) |
| 27 |
assert_match(/irb\(main\):002> 456/, output) |
| 28 |
refute_match(/Third line\r\n/, output) |
| 29 |
refute_match(/Fourth line\r\n/, output) |
| 30 |
end |
| 31 |
|
| 32 |
def test_forced_exit_in_nested_sessions |
| 33 |
write_ruby <<~'ruby' |
| 34 |
def foo |
| 35 |
binding.irb |
| 36 |
end |
| 37 |
|
| 38 |
binding.irb |
| 39 |
binding.irb |
| 40 |
ruby |
| 41 |
|
| 42 |
output = run_ruby_file do |
| 43 |
type "123" |
| 44 |
type "foo" |
| 45 |
type "exit!" |
| 46 |
end |
| 47 |
|
| 48 |
assert_match(/irb\(main\):001> 123/, output) |
| 49 |
end |
| 50 |
end |
| 51 |
end |