Skip to content

Commit

Permalink
Add test for show_cmds pager's termination
Browse files Browse the repository at this point in the history
  • Loading branch information
st0012 committed Jul 17, 2023
1 parent 9074521 commit 3665d4a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/irb/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,24 @@ def test_assignment_expression_truncate
EOC
end

def test_show_cmds_with_pager_can_quit_with_ctrl_c
write_irbrc <<~'LINES'
puts 'start IRB'
LINES
start_terminal(40, 80, %W{ruby -I#{@pwd}/lib #{@pwd}/exe/irb}, startup_message: 'start IRB')
write("show_cmds\n")
write("G") # move to the end of the screen
write("\C-c") # quit pager
close

screen = result.join("\n").sub(/\n*\z/, "\n")
# IRB::Abort should be rescued
assert_not_match(/IRB::Abort/, screen)
# IRB should resume
assert_not_match(/END/, screen)
assert_match(/=> nil/, screen)
end

private

def write_irbrc(content)
Expand Down

0 comments on commit 3665d4a

Please sign in to comment.