ttytest2 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/lib/ttytest/matchers.rb +31 -4
- data/lib/ttytest/version.rb +1 -1
- data/notes.txt +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3f08a4827e337de7e9124c7c0daf929922f9c6dfb573a03e88ee5e23b243cf9
|
4
|
+
data.tar.gz: 1f4ae48c6dff1ce25ea0a22c6f29c188b98caee3efa2a512132e4c416a522185
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edc7cb24ffec16991743b8dd104050f594f78a68ed44b88df91e2ce3ba52045dd0d37548b978a1bc47e0bd424d3dd8b1b75b9cce231f323bb6f860e2fb6ef7e4
|
7
|
+
data.tar.gz: 8d7e3f220552cc6485fa848e046eb6711e18117f43d6fb99d1fdc1751391da3e0aa719cc5c50b34dd3a4256eb89e17fec5a3868d32084074909af68110570283
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Forked from https://github.com/jhawthorn/ttytest, because I had some features I
|
|
6
6
|
|
7
7
|
It works by running commands inside a tmux session, capturing the pane, and comparing the content. The assertions will wait a specified amount of time (default 2 seconds) for the expected content to appear.
|
8
8
|
|
9
|
-
[](https://rubygems.org/gems/ttytest2)
|
10
10
|
|
11
11
|
## Minimum Requirements
|
12
12
|
|
@@ -18,6 +18,8 @@ It works by running commands inside a tmux session, capturing the pane, and comp
|
|
18
18
|
### Example
|
19
19
|
|
20
20
|
``` ruby
|
21
|
+
require 'ttytest'
|
22
|
+
|
21
23
|
@tty = TTYtest.new_terminal(%{PS1='$ ' /bin/sh}, width: 80, height: 24)
|
22
24
|
@tty.assert_row(0, '$')
|
23
25
|
@tty.assert_cursor_position(x: 2, y: 0)
|
@@ -41,6 +43,8 @@ The main way to use TTYtest is through assertions. When called on a `TTYtest::Te
|
|
41
43
|
Available assertions:
|
42
44
|
* `assert_row(row_number, expected_text)`
|
43
45
|
* `assert_row_like(row_number, expected_text)`
|
46
|
+
* `assert_row_starts_with(row_number, expected_text)`
|
47
|
+
* `assert_row_ends_with(row_number, expected_text)`
|
44
48
|
* `assert_cursor_position(x: x, y: y)`
|
45
49
|
* `assert_cursor_visible`
|
46
50
|
* `assert_cursor_hidden`
|
data/lib/ttytest/matchers.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module TTYtest
|
2
|
+
# Assertions for ttytest2.
|
2
3
|
module Matchers
|
3
4
|
# Asserts the contents of a single row
|
4
5
|
# @param [Integer] row_number the row (starting from 0) to test against
|
@@ -7,15 +8,15 @@ module TTYtest
|
|
7
8
|
def assert_row(row_number, expected)
|
8
9
|
expected = expected.rstrip
|
9
10
|
actual = row(row_number)
|
10
|
-
return
|
11
|
+
return if actual == expected
|
11
12
|
|
12
13
|
raise MatchError,
|
13
14
|
"expected row #{row_number} to be #{expected.inspect} but got #{actual.inspect}\nEntire screen:\n#{self}"
|
14
15
|
end
|
15
16
|
|
16
|
-
# Asserts the contents of a single row
|
17
|
+
# Asserts the contents of a single row contains expected
|
17
18
|
# @param [Integer] row_number the row (starting from 0) to test against
|
18
|
-
# @param [String] expected the expected value
|
19
|
+
# @param [String] expected the expected value contained in the row. Any trailing whitespace is ignored
|
19
20
|
# @raise [MatchError] if the row doesn't match
|
20
21
|
def assert_row_like(row_number, expected)
|
21
22
|
expected = expected.rstrip
|
@@ -26,6 +27,32 @@ module TTYtest
|
|
26
27
|
"expected row #{row_number} to be like #{expected.inspect} but got #{actual.inspect}\nEntire screen:\n#{self}"
|
27
28
|
end
|
28
29
|
|
30
|
+
# Asserts the contents of a single row start with expected
|
31
|
+
# @param [Integer] row_number the row (starting from 0) to test against
|
32
|
+
# @param [String] expected the expected value that the row starts with. Any trailing whitespace is ignored
|
33
|
+
# @raise [MatchError] if the row doesn't match
|
34
|
+
def assert_row_starts_with(row_number, expected)
|
35
|
+
expected = expected.rstrip
|
36
|
+
actual = row(row_number)
|
37
|
+
return if actual.start_with?(expected)
|
38
|
+
|
39
|
+
raise MatchError,
|
40
|
+
"expected row #{row_number} to start with #{expected.inspect} and got #{actual.inspect}\nEntire screen:\n#{self}"
|
41
|
+
end
|
42
|
+
|
43
|
+
# Asserts the contents of a single row end with expected
|
44
|
+
# @param [Integer] row_number the row (starting from 0) to test against
|
45
|
+
# @param [String] expected the expected value that the row starts with. Any trailing whitespace is ignored
|
46
|
+
# @raise [MatchError] if the row doesn't match
|
47
|
+
def assert_row_ends_with(row_number, expected)
|
48
|
+
expected = expected.rstrip
|
49
|
+
actual = row(row_number)
|
50
|
+
return if actual.end_with?(expected)
|
51
|
+
|
52
|
+
raise MatchError,
|
53
|
+
"expected row #{row_number} to end with #{expected.inspect} and got #{actual.inspect}\nEntire screen:\n#{self}"
|
54
|
+
end
|
55
|
+
|
29
56
|
# Asserts that the cursor is in the expected position
|
30
57
|
# @param [Integer] x cursor x (row) position, starting from 0
|
31
58
|
# @param [Integer] y cursor y (column) position, starting from 0
|
@@ -33,7 +60,7 @@ module TTYtest
|
|
33
60
|
def assert_cursor_position(x, y)
|
34
61
|
expected = [x, y]
|
35
62
|
actual = [cursor_x, cursor_y]
|
36
|
-
return
|
63
|
+
return if actual == expected
|
37
64
|
|
38
65
|
raise MatchError,
|
39
66
|
"expected cursor to be at #{expected.inspect} but was at #{actual.inspect}\nEntire screen:\n#{self}"
|
data/lib/ttytest/version.rb
CHANGED
data/notes.txt
CHANGED