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 an assertion before failing and raising a MatchError.
-
#use_return_for_newline ⇒ Object
Returns the value of attribute use_return_for_newline.
Instance Method Summary collapse
-
#capture ⇒ Capture
Capture represents 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, use_return_for_newline) ⇒ Terminal
constructor
private
Internal constructor.
-
#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(number_of_times) ⇒ 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(number_of_times) ⇒ 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(number_of_times) ⇒ Object
Simulates typing the down arrow the specified number of times.
-
#send_end ⇒ Object
Simulates typing in the End key in the terminal.
-
#send_escape ⇒ Object
Simulates typing in the Escape (ESC) key in the terminal.
-
#send_escapes(number_of_times) ⇒ Object
Simulates typing in the Escape (ESC) key in the terminal the specified number of times.
-
#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(keys) ⇒ 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(number_of_times) ⇒ Object
Simulates typing left arrow the specified number of times.
-
#send_line(line) ⇒ Object
Simulate sending a line to the terminal and hitting enter.
-
#send_line_exact(line) ⇒ Object
Simulate sending a line exactly as is to the terminal and hitting enter.
-
#send_line_then_sleep(line, sleep_time) ⇒ Object
Simulate sending a line to the terminal and hitting enter, then sleeping for sleep_time.
-
#send_line_then_sleep_and_repeat(lines, sleep_time) ⇒ Object
Simulate sending a line to the terminal and hitting enter, then sleeping for sleep_time.
-
#send_lines(lines) ⇒ Object
Simulate sending a multiple lines to the terminal and hitting enter after each line.
-
#send_lines_exact(lines) ⇒ Object
Simulate sending a multiple lines exactly as is to the terminal and hitting enter after each line.
-
#send_lines_then_sleep(lines, sleep_time) ⇒ Object
Simulate sending multiples lines to the terminal and hitting enter after each line.
-
#send_newline ⇒ Object
Simulate typing enter by sending newline (ALT + enter) character to the terminal.
-
#send_newlines(number_of_times) ⇒ Object
Simulates sending newline (ALT + enter) the specified number of times.
-
#send_return ⇒ Object
Simulate typing enter by sending newline character to the terminal.
-
#send_returns(number_of_times) ⇒ 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(number_of_times) ⇒ Object
Simulates typing right arrow the specified number of times.
-
#send_tab ⇒ Object
Simulates typing in the Tab (t) key in the terminal.
-
#send_tabs(number_of_times) ⇒ Object
Simulates typing in the Tab (t) key in the terminal the specified number of times.
-
#send_up_arrow ⇒ Object
Simulate typing the up arrow key in the terminal.
-
#send_up_arrows(number_of_times) ⇒ Object
Simulates typing the up arrow the specified number of times.
- #width ⇒ Integer
Constructor Details
#initialize(driver_terminal, max_wait_time, use_return_for_newline) ⇒ 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.
Internal constructor.
17 18 19 20 21 |
# File 'lib/ttytest/terminal.rb', line 17 def initialize(driver_terminal, max_wait_time, use_return_for_newline) @max_wait_time = max_wait_time @use_return_for_newline = use_return_for_newline @driver_terminal = driver_terminal end |
Instance Attribute Details
#max_wait_time ⇒ Integer
The maximum amount of time (in seconds) to retry an assertion before failing and raising a MatchError.
9 10 11 |
# File 'lib/ttytest/terminal.rb', line 9 def max_wait_time @max_wait_time end |
#use_return_for_newline ⇒ Object
Returns the value of attribute use_return_for_newline.
12 13 14 |
# File 'lib/ttytest/terminal.rb', line 12 def use_return_for_newline @use_return_for_newline end |
Instance Method Details
#capture ⇒ Capture
Capture represents the current state of the terminal.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/ttytest/terminal.rb', line 160 def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_line, :send_line_then_sleep, :send_lines, :send_lines_then_sleep, :send_line_then_sleep_and_repeat, :send_line_exact, :send_lines_exact, :send_newline, :send_newlines, :send_enter, :send_enters, :send_return, :send_returns, :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, :send_escape, :send_escapes, :send_tab, :send_tabs, :capture |
#cursor_hidden? ⇒ true, false
204 205 206 207 208 |
# File 'lib/ttytest/terminal.rb', line 204 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#cursor_visible? ⇒ true, false
204 205 206 207 208 |
# File 'lib/ttytest/terminal.rb', line 204 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#cursor_x ⇒ Integer
204 205 206 207 208 |
# File 'lib/ttytest/terminal.rb', line 204 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#cursor_y ⇒ Integer
204 205 206 207 208 |
# File 'lib/ttytest/terminal.rb', line 204 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#height ⇒ Integer
204 205 206 207 208 |
# File 'lib/ttytest/terminal.rb', line 204 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.
204 205 206 207 208 |
# File 'lib/ttytest/terminal.rb', line 204 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.
204 205 206 207 208 |
# File 'lib/ttytest/terminal.rb', line 204 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#row(row) ⇒ String
204 205 206 207 208 |
# File 'lib/ttytest/terminal.rb', line 204 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |
#rows ⇒ Array<String>
204 205 206 207 208 |
# File 'lib/ttytest/terminal.rb', line 204 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.
|
|
# File 'lib/ttytest/terminal.rb', line 95
|
#send_backspaces(number_of_times) ⇒ Object
Simulates typing backspace the specified number of times.
|
|
# File 'lib/ttytest/terminal.rb', line 98
|
#send_clear ⇒ Object
Clears the screen in the terminal using ascii clear command.
|
|
# File 'lib/ttytest/terminal.rb', line 140
|
#send_delete ⇒ Object
Simulate typing the delete key in the terminal.
|
|
# File 'lib/ttytest/terminal.rb', line 88
|
#send_deletes(number_of_times) ⇒ Object
Simulates typing delete the specified number of times.
|
|
# File 'lib/ttytest/terminal.rb', line 91
|
#send_down_arrow ⇒ Object
Simulate typing the down arrow key in the terminal.
|
|
# File 'lib/ttytest/terminal.rb', line 116
|
#send_down_arrows(number_of_times) ⇒ Object
Simulates typing the down arrow the specified number of times.
|
|
# File 'lib/ttytest/terminal.rb', line 119
|
#send_end ⇒ Object
Simulates typing in the End key in the terminal.
|
|
# File 'lib/ttytest/terminal.rb', line 137
|
#send_escape ⇒ Object
Simulates typing in the Escape (ESC) key in the terminal.
|
|
# File 'lib/ttytest/terminal.rb', line 143
|
#send_escapes(number_of_times) ⇒ Object
Simulates typing in the Escape (ESC) key in the terminal the specified number of times.
|
|
# File 'lib/ttytest/terminal.rb', line 146
|
#send_home ⇒ Object
Simulates typing in the Home key in the terminal.
|
|
# File 'lib/ttytest/terminal.rb', line 134
|
#send_keys(*keys) ⇒ Object
Simulate typing keys into the terminal. For canonical cli’s/shells which read line by line.
|
|
# File 'lib/ttytest/terminal.rb', line 23
|
#send_keys_exact(keys) ⇒ Object
Send tmux send-keys command to the terminal, such as DC or Enter, to simulate pressing that key in the terminal.
|
|
# File 'lib/ttytest/terminal.rb', line 130
|
#send_keys_one_at_a_time(keys) ⇒ Object
Simulate typing keys into the terminal. For noncanonical cli’s/shells which read character by character.
|
|
# File 'lib/ttytest/terminal.rb', line 27
|
#send_left_arrow ⇒ Object
Simulate typing the left arrow key in the terminal.
|
|
# File 'lib/ttytest/terminal.rb', line 102
|
#send_left_arrows(number_of_times) ⇒ Object
Simulates typing left arrow the specified number of times.
|
|
# File 'lib/ttytest/terminal.rb', line 105
|
#send_line(line) ⇒ Object
Simulate sending a line to the terminal and hitting enter. Can send multiline input, but if you want to send several commands at once, see send_lines(lines) If no newline is at the the line, it will be appended automatically.
|
|
# File 'lib/ttytest/terminal.rb', line 31
|
#send_line_exact(line) ⇒ Object
Simulate sending a line exactly as is to the terminal and hitting enter. Can send multiline input, but if you want to send several commands at once, see send_lines(lines) If no newline is at the the line, it will be appended automatically.
|
|
# File 'lib/ttytest/terminal.rb', line 47
|
#send_line_then_sleep(line, sleep_time) ⇒ Object
Simulate sending a line to the terminal and hitting enter, then sleeping for sleep_time.
|
|
# File 'lib/ttytest/terminal.rb', line 37
|
#send_line_then_sleep_and_repeat(lines, sleep_time) ⇒ Object
Simulate sending a line to the terminal and hitting enter, then sleeping for sleep_time. before sending the next line.
|
|
# File 'lib/ttytest/terminal.rb', line 64
|
#send_lines(lines) ⇒ Object
Simulate sending a multiple lines to the terminal and hitting enter after each line. If no newline is at the end of any of the lines, it will be appended automatically.
|
|
# File 'lib/ttytest/terminal.rb', line 42
|
#send_lines_exact(lines) ⇒ Object
Simulate sending a multiple lines exactly as is to the terminal and hitting enter after each line. If no newline is at the end of any of the lines, it will be appended automatically.
|
|
# File 'lib/ttytest/terminal.rb', line 53
|
#send_lines_then_sleep(lines, sleep_time) ⇒ Object
Simulate sending multiples lines to the terminal and hitting enter after each line. After sending all lines, then wait for the sleep_time.
|
|
# File 'lib/ttytest/terminal.rb', line 58
|
#send_newline ⇒ Object
Simulate typing enter by sending newline (ALT + enter) character to the terminal. Many line readers interpreter newline as return, but in some cases you may have to use send_return.
|
|
# File 'lib/ttytest/terminal.rb', line 70
|
#send_newlines(number_of_times) ⇒ Object
Simulates sending newline (ALT + enter) the specified number of times. Many line readers interpreter newline as return, but in some cases you may have to use send_return.
|
|
# File 'lib/ttytest/terminal.rb', line 74
|
#send_return ⇒ Object
Simulate typing enter by sending newline character to the terminal. Many line readers interpreter newline as return, but in some cases you may have to use send_return.
|
|
# File 'lib/ttytest/terminal.rb', line 79
|
#send_returns(number_of_times) ⇒ Object
Simulates sending newline the specified number of times. Many line readers interpreter newline as return, but in some cases you may have to use send_return.
|
|
# File 'lib/ttytest/terminal.rb', line 83
|
#send_right_arrow ⇒ Object
Simulate typing the right arrow key in the terminal.
|
|
# File 'lib/ttytest/terminal.rb', line 109
|
#send_right_arrows(number_of_times) ⇒ Object
Simulates typing right arrow the specified number of times.
|
|
# File 'lib/ttytest/terminal.rb', line 112
|
#send_tab ⇒ Object
Simulates typing in the Tab (t) key in the terminal.
|
|
# File 'lib/ttytest/terminal.rb', line 150
|
#send_tabs(number_of_times) ⇒ Object
Simulates typing in the Tab (t) key in the terminal the specified number of times.
|
|
# File 'lib/ttytest/terminal.rb', line 153
|
#send_up_arrow ⇒ Object
Simulate typing the up arrow key in the terminal.
|
|
# File 'lib/ttytest/terminal.rb', line 123
|
#send_up_arrows(number_of_times) ⇒ Object
Simulates typing the up arrow the specified number of times.
|
|
# File 'lib/ttytest/terminal.rb', line 126
|
#width ⇒ Integer
204 205 206 207 208 |
# File 'lib/ttytest/terminal.rb', line 204 def_delegators :capture, :print, :print_rows, :rows, :row, :width, :height, :cursor_x, :cursor_y, :cursor_visible?, :cursor_hidden? |