Module: TTYtest::CursorAssertions

Included in:
Assertions
Defined in:
lib/ttytest/assertions/cursor_assertions.rb

Overview

Cursor Assertions for ttytest2.

Instance Method Summary collapse

Instance Method Details

#assert_cursor_hiddenObject

Asserts the cursor is currently hidden

Raises:



30
31
32
33
34
# File 'lib/ttytest/assertions/cursor_assertions.rb', line 30

def assert_cursor_hidden
  return if cursor_hidden?

  raise MatchError, "expected cursor to be hidden was visible\nEntire screen:\n#{self}"
end

#assert_cursor_position(x, y) ⇒ Object

Asserts that the cursor is in the expected position

Parameters:

  • x (Integer)

    cursor x (row) position, starting from 0

  • y (Integer)

    cursor y (column) position, starting from 0

Raises:

  • (MatchError)

    if the cursor position doesn’t match



10
11
12
13
14
15
16
17
18
# File 'lib/ttytest/assertions/cursor_assertions.rb', line 10

def assert_cursor_position(x, y)
  expected = [x, y]
  actual = [cursor_x, cursor_y]

  return if actual == expected

  raise MatchError,
        "expected cursor to be at #{expected.inspect} but was at #{get_inspection(actual)}\nEntire screen:\n#{self}"
end

#assert_cursor_visibleObject

Asserts the cursor is currently visible

Raises:



22
23
24
25
26
# File 'lib/ttytest/assertions/cursor_assertions.rb', line 22

def assert_cursor_visible
  return if cursor_visible?

  raise MatchError, "expected cursor to be visible was hidden\nEntire screen:\n#{self}"
end