examples/canonical_integration_tests.rb in ttytest2-0.9.4 vs examples/canonical_integration_tests.rb in ttytest2-0.9.5
- old
+ new
@@ -1,8 +1,10 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
+# example testing a noncanonical shell, ncsh
+
require 'ttytest'
START_COL = 19
def assert_check_new_row(row)
@@ -53,40 +55,30 @@
@tty.send_backspace
assert_check_new_row(row)
# multiple end of line backspaces
@tty.send_keys(%(lsssss))
-@tty.send_backspace
-@tty.send_backspace
-@tty.send_backspace
-@tty.send_backspace
-@tty.assert_row_ends_with(row, '$ ls')
-@tty.send_backspace
-@tty.send_backspace
+@tty.send_backspaces(4)
+@tty.assert_row_ends_with(row, 'ls')
+@tty.send_backspaces(2)
@tty.send_keys(%(echo hello)) # make sure buffer is properly formed after backspaces
@tty.send_newline
row += 1
@tty.assert_row(row, 'hello')
row += 1
# midline backspace
assert_check_new_row(row)
@tty.send_keys(%(lsssss))
@tty.assert_cursor_position(START_COL + 6, row)
-@tty.send_keys(TTYtest::LEFT_ARROW)
-@tty.send_keys(TTYtest::LEFT_ARROW)
+@tty.send_left_arrows(2)
@tty.assert_cursor_position(START_COL + 4, row)
-@tty.send_backspace
-@tty.send_backspace
-@tty.send_backspace
-@tty.send_backspace
+@tty.send_backspaces(4)
@tty.assert_cursor_position(START_COL, row)
@tty.assert_row_ends_with(row, '$ ss')
-@tty.send_keys(TTYtest::RIGHT_ARROW)
-@tty.send_keys(TTYtest::RIGHT_ARROW)
+@tty.send_right_arrows(2)
@tty.assert_cursor_position(START_COL + 2, row)
-@tty.send_backspace
-@tty.send_backspace
+@tty.send_backspaces(2)
@tty.assert_cursor_position(START_COL, row)
@tty.send_keys(%(echo hello)) # make sure buffer is properly formed after backspaces
@tty.send_newline
row += 1
@tty.assert_row(row, 'hello')