Module: TTYtest

Extended by:
Forwardable
Defined in:
lib/ttytest.rb,
lib/ttytest/capture.rb,
lib/ttytest/version.rb,
lib/ttytest/terminal.rb,
lib/ttytest/constants.rb,
lib/ttytest/assertions.rb,
lib/ttytest/tmux/driver.rb,
lib/ttytest/tmux/session.rb,
lib/ttytest/assertions/row_assertions.rb,
lib/ttytest/assertions/file_assertions.rb,
lib/ttytest/assertions/column_assertions.rb,
lib/ttytest/assertions/cursor_assertions.rb,
lib/ttytest/assertions/screen_assertions.rb,
lib/ttytest/assertions/exit_code_assertions.rb

Overview

some constants that can be used with send_keys, just to help out people creating tests

Defined Under Namespace

Modules: Assertions, ColumnAssertions, CursorAssertions, ExitCodeAssertions, FileAssertions, RowAssertions, ScreenAssertions, Tmux Classes: Capture, MatchError, Terminal

Constant Summary collapse

VERSION =
'1.6.1'
CTRLA =
1.chr
CTRLB =
2.chr
CTRLC =
3.chr
CTRLD =
4.chr
CTRLF =
6.chr
BELL =
7.chr
BACKSPACE =
8.chr
TAB =

t

9.chr
NEWLINE =

n

10.chr
ENTER =

n

10.chr
VERTICAL_TAB =

v

11.chr
SHIFT_ENTER =

v

11.chr
FORM_FEED =

f

12.chr
CTRLL =
12.chr
CARRIAGE_RETURN =

r, left for backwards compat

13.chr
RETURN =

r, same as CARRIAGE_RETURN

13.chr
CTRLU =
21.chr
CTRLW =
23.chr
ESCAPE =

^[ or /033 or /e

27.chr
CTRL_ =
31.chr
DELETE =
127.chr
UP_ARROW =
"#{ESCAPE}[A".freeze
DOWN_ARROW =
"#{ESCAPE}[B".freeze
RIGHT_ARROW =
"#{ESCAPE}[C".freeze
LEFT_ARROW =
"#{ESCAPE}[D".freeze
HOME_KEY =
"#{ESCAPE}[H".freeze
END_KEY =
"#{ESCAPE}[F".freeze
CLEAR =
"#{ESCAPE}[2J".freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.default_max_wait_timeObject

Returns the value of attribute default_max_wait_time.



11
12
13
# File 'lib/ttytest.rb', line 11

def default_max_wait_time
  @default_max_wait_time
end

.driverObject

Returns the value of attribute driver.



11
12
13
# File 'lib/ttytest.rb', line 11

def driver
  @driver
end

Class Method Details

.new_default_sh_terminalTerminal

Create a new terminal using ‘/bin/sh’ with width: 80 and height: 24. Useful for applications like shells which may show user or the cwd.

Returns:



# File 'lib/ttytest.rb', line 23

.new_sh_terminal(width: 80, height: 24, max_wait_time: 2, use_return_for_newline: false) ⇒ Terminal

Create a new terminal using ‘/bin/sh’ with ability to set width and height. Useful for applications like shells which may show user or the cwd.

Parameters:

  • max_wait_time (Integer) (defaults to: 2)

    max time to wait for screen to update before an assertion fails

  • use_return_for_newline (bool) (defaults to: false)

    use return instead of newline for functions like send_line

Returns:

  • (Terminal)

    a new sh terminal with specified width and height



35
# File 'lib/ttytest.rb', line 35

def_delegators :driver

.new_terminal(cmd, width: 80, height: 24, max_wait_time: 2, use_return_for_newline: false) ⇒ Terminal

Create a new terminal through the current driver.

Parameters:

  • command (String)

    a valid shell command to run

  • width (Integer) (defaults to: 80)

    width of the new terminal

  • height (Integer) (defaults to: 24)

    height of the new terminal

  • max_wait_time (Integer) (defaults to: 2)

    max time to wait for screen to update before an assertion fails

  • use_return_for_newline (bool) (defaults to: false)

    use return instead of newline for functions like send_line

Returns:

  • (Terminal)

    a new terminal running the specified command



# File 'lib/ttytest.rb', line 14