Class: TTYtest::Terminal
- Inherits:
-
Object
- Object
- TTYtest::Terminal
- Extended by:
- Forwardable
- Defined in:
- lib/ttytest/terminal.rb
Instance Attribute Summary collapse
-
#max_wait_time ⇒ Integer
the maximum amount of time (in seconds) to retry assertions before failing.
Instance Method Summary collapse
-
#capture ⇒ Capture
Capture the current state of the terminal.
- #cursor_hidden? ⇒ true, false
- #cursor_visible? ⇒ true, false
- #cursor_x ⇒ Integer
- #cursor_y ⇒ Integer
- #height ⇒ Integer
-
#initialize(driver_terminal, max_wait_time: nil) ⇒ Terminal
constructor
private
A new instance of Terminal.
-
#print ⇒ Object
Prints the current state of the terminal to stdout.
-
#print_rows ⇒ Object
Prints the current state of the terminal as an array to stdout.
- #row(row) ⇒ String
- #rows ⇒ Array<String>
-
#send_backspace ⇒ Object
Simulate typing the backspace key in the terminal.
-
#send_backspaces ⇒ Object
Simulates typing backspace the specified number of times.
-
#send_clear ⇒ Object
Clears the screen in the terminal using ascii clear command.
-
#send_delete ⇒ Object
Simulate typing the delete key in the terminal.
-
#send_deletes ⇒ Object
Simulates typing delete the specified number of times.
-
#send_down_arrow ⇒ Object
Simulate typing the down arrow key in the terminal.
-
#send_down_arrows ⇒ Object
Simulates typing the down arrow the specified number of times.
-
#send_end ⇒ Object
Simulates typing in the End key in the terminal.
-
#send_home ⇒ Object
Simulates typing in the Home key in the terminal.
-
#send_keys(*keys) ⇒ Object
Simulate typing keys into the terminal.
-
#send_keys_exact ⇒ Object
Send tmux send-keys command to the terminal, such as DC or Enter, to simulate pressing that key in the terminal.
-
#send_keys_one_at_a_time(keys) ⇒ Object
Simulate typing keys into the terminal.
-
#send_left_arrow ⇒ Object
Simulate typing the left arrow key in the terminal.
-
#send_left_arrows ⇒ Object
Simulates typing left arrow the specified number of times.
-
#send_newline ⇒ Object
Simulate typing enter by sending newline character to the terminal.
-
#send_newlines ⇒ Object
Simulates sending newline the specified number of times.
-
#send_right_arrow ⇒ Object
Simulate typing the right arrow key in the terminal.
-
#send_right_arrows ⇒ Object
Simulates typing right arrow the specified number of times.
-
#send_up_arrow ⇒ Object
Simulate typing the up arrow key in the terminal.
-
#send_up_arrows ⇒ Object
Simulates typing the up arrow the specified number of times.
- #width ⇒ Integer
Constructor Details
#initialize(driver_terminal, max_wait_time: nil) ⇒ Terminal
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Terminal.
16 17 18 19 |
# File 'lib/ttytest/terminal.rb', line 16 def initialize(driver_terminal, max_wait_time: nil) @driver_terminal = driver_terminal @max_wait_time = max_wait_time || TTYtest.default_max_wait_time end |
Instance Attribute Details
#max_wait_time ⇒ Integer
the maximum amount of time (in seconds) to retry assertions before failing.
9 10 11 |
# File 'lib/ttytest/terminal.rb', line 9 def max_wait_time @max_wait_time end |
Instance Method Details
#capture ⇒ Capture
Capture the current state of the terminal
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#cursor_hidden? ⇒ true, false
111 112 113 114 115 |
# File 'lib/ttytest/terminal.rb', line 111 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#cursor_visible? ⇒ true, false
111 112 113 114 115 |
# File 'lib/ttytest/terminal.rb', line 111 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#cursor_x ⇒ Integer
111 112 113 114 115 |
# File 'lib/ttytest/terminal.rb', line 111 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#cursor_y ⇒ Integer
111 112 113 114 115 |
# File 'lib/ttytest/terminal.rb', line 111 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#height ⇒ Integer
111 112 113 114 115 |
# File 'lib/ttytest/terminal.rb', line 111 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#print ⇒ Object
Prints the current state of the terminal to stdout. See capture to get the raw string.
111 112 113 114 115 |
# File 'lib/ttytest/terminal.rb', line 111 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#print_rows ⇒ Object
Prints the current state of the terminal as an array to stdout. See rows to get the raw array.
111 112 113 114 115 |
# File 'lib/ttytest/terminal.rb', line 111 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#row(row) ⇒ String
111 112 113 114 115 |
# File 'lib/ttytest/terminal.rb', line 111 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#rows ⇒ Array<String>
111 112 113 114 115 |
# File 'lib/ttytest/terminal.rb', line 111 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#send_backspace ⇒ Object
Simulate typing the backspace key in the terminal.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_backspaces ⇒ Object
Simulates typing backspace the specified number of times.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_clear ⇒ Object
Clears the screen in the terminal using ascii clear command.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_delete ⇒ Object
Simulate typing the delete key in the terminal.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_deletes ⇒ Object
Simulates typing delete the specified number of times.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_down_arrow ⇒ Object
Simulate typing the down arrow key in the terminal.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_down_arrows ⇒ Object
Simulates typing the down arrow the specified number of times.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_end ⇒ Object
Simulates typing in the End key in the terminal.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_home ⇒ Object
Simulates typing in the Home key in the terminal.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_keys(*keys) ⇒ Object
Simulate typing keys into the terminal. For canonical cli’s/shells which read line by line.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_keys_exact ⇒ Object
Send tmux send-keys command to the terminal, such as DC or Enter, to simulate pressing that key in the terminal.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_keys_one_at_a_time(keys) ⇒ Object
Simulate typing keys into the terminal. For noncanonical cli’s/shells which read character by character.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_left_arrow ⇒ Object
Simulate typing the left arrow key in the terminal.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_left_arrows ⇒ Object
Simulates typing left arrow the specified number of times.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_newline ⇒ Object
Simulate typing enter by sending newline character to the terminal.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_newlines ⇒ Object
Simulates sending newline the specified number of times.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_right_arrow ⇒ Object
Simulate typing the right arrow key in the terminal.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_right_arrows ⇒ Object
Simulates typing right arrow the specified number of times.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_up_arrow ⇒ Object
Simulate typing the up arrow key in the terminal.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#send_up_arrows ⇒ Object
Simulates typing the up arrow the specified number of times.
73 74 75 76 77 78 79 80 81 |
# File 'lib/ttytest/terminal.rb', line 73 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :send_newlines, :send_delete, :send_deletes, :send_backspace, :send_backspaces, :send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows, :send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows, :send_keys_exact, :send_home, :send_end, :send_clear, :capture |
#width ⇒ Integer
111 112 113 114 115 |
# File 'lib/ttytest/terminal.rb', line 111 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |