ttytest2 1.3.0 → 1.5.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/LICENSE +8 -0
- data/README.md +52 -16
- data/lib/ttytest/assertions/column_assertions.rb +127 -0
- data/lib/ttytest/assertions/exit_code_assertions.rb +13 -0
- data/lib/ttytest/assertions/file_assertions.rb +1 -1
- data/lib/ttytest/assertions/row_assertions.rb +3 -4
- data/lib/ttytest/tmux/session.rb +23 -4
- data/lib/ttytest/version.rb +1 -1
- data/lib/ttytest.rb +2 -4
- data/notes.txt +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7bf4ac747757d3aeaf01d103d15708cf487834ed43b9e3dad90e0d94e5203bc
|
4
|
+
data.tar.gz: 901c844e8719e6652943aae004e5f3deada174c4ab312e2e1c5956f496aa64c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '02128e6d6ada7be932b624b5dd48c4d7eef0ace8a3d727629f7c756f4e5b0027b00aa6fe96040a38ff84178e0b74256e644584376e8d6784c48728662e50af3d'
|
7
|
+
data.tar.gz: a2909a072f201511eed7e77b72a67143b0fb9caa2dac07aa583696aa040e88c34a2188644b1a0872d4309cfe8b2ef7e30d271a68b97f298b4334948dd879a3a6
|
data/LICENSE
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Copyright (c) 2016-2025 John Hawthorn
|
2
|
+
Copyright (c) 2024-2025 Alex Eski
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -4,13 +4,13 @@
|
|
4
4
|
<img src="images/ttytest2.png" alt="ttytest2 logo" style="width:70%; height:auto;">
|
5
5
|
</a>
|
6
6
|
|
7
|
-
ttytest2 is a
|
7
|
+
ttytest2 is a integration test framework for CLI, TUI, & shell applications.
|
8
8
|
|
9
9
|
ttytest2 is a fork and a drop-in replacement for [ttytest](https://github.com/jhawthorn/ttytest).
|
10
10
|
|
11
11
|
It works by creating a tmux session behind the scenes, running the specified commands, capturing the pane, and then comparing the actual content to the expected content based on the assertions made.
|
12
12
|
|
13
|
-
The assertions will wait a
|
13
|
+
The assertions will wait a configuable amount of time (default 2 seconds) for the expected content to appear before failing.
|
14
14
|
|
15
15
|
[](https://badge.fury.io/rb/ttytest2)
|
16
16
|
|
@@ -38,6 +38,8 @@ The assertions will wait a specified amount of time (configurable, default 2 sec
|
|
38
38
|
* Download the [gem](https://rubygems.org/gems/ttytest2) here.
|
39
39
|
* More documentation available at [ttytest2 docs](https://www.rubydoc.info/gems/ttytest2).
|
40
40
|
* There are more examples in the examples folder.
|
41
|
+
* Synchronous example: [ncsh synchronous tests](https://github.com/a-eski/ncsh/blob/main/acceptance_tests/tests/acceptance_tests.rb)
|
42
|
+
* Concurrent & generated example: [ncsh concurrent tests](https://github.com/a-eski/ncsh/blob/main/acceptance_tests/minitest/tests.rb)
|
41
43
|
|
42
44
|
### Simple Example
|
43
45
|
|
@@ -77,11 +79,11 @@ TTY
|
|
77
79
|
|
78
80
|
Call one of these methods to initialize an instance of ttytest2.
|
79
81
|
|
80
|
-
* `new_terminal(cmd, width, height)`: initialize new tmux terminal instance and run cmd.
|
82
|
+
* `new_terminal(cmd, width, height, max_wait_time, use_return_for_newline)`: initialize new tmux terminal instance and run cmd.
|
81
83
|
|
82
84
|
* `new_default_sh_terminal()`: intialize new tmux terminal instance using sh, width of 80, height of 24.
|
83
85
|
|
84
|
-
* `new_sh_terminal(width, height)`: intialize new tmux terminal instance using sh
|
86
|
+
* `new_sh_terminal(width, height, max_wait_time, use_return_for_newline)`: intialize new tmux terminal instance using sh.
|
85
87
|
|
86
88
|
``` ruby
|
87
89
|
require 'ttytest'
|
@@ -96,6 +98,8 @@ require 'ttytest'
|
|
96
98
|
# you can also use other shells, like bash
|
97
99
|
@tty = TTYtest.new_terminal('/bin/bash')
|
98
100
|
@tty = TTYtest.new_terminal('/bin/bash', width: 80, height: 24)
|
101
|
+
|
102
|
+
# you can specify further options, see section Configurables.
|
99
103
|
```
|
100
104
|
|
101
105
|
## Assertions
|
@@ -112,6 +116,8 @@ If you are reading this on github, the ruby docs accessible from [RubyDoc.Info](
|
|
112
116
|
|
113
117
|
### Available Assertions
|
114
118
|
|
119
|
+
#### Row Assertions
|
120
|
+
|
115
121
|
* `assert_row(row_number, expected_text)`
|
116
122
|
|
117
123
|
* `assert_row_is_empty(row_number)`
|
@@ -128,12 +134,32 @@ If you are reading this on github, the ruby docs accessible from [RubyDoc.Info](
|
|
128
134
|
|
129
135
|
* `assert_rows_each_match_regexp(row_start, row_end, regexp_str)`
|
130
136
|
|
137
|
+
#### Column Assertions
|
138
|
+
|
139
|
+
* `assert_column(col_number, expected_text)`
|
140
|
+
|
141
|
+
* `assert_column_is_empty(col_number)`
|
142
|
+
|
143
|
+
* `assert_column_at(col_number, row_start, row_end, expected_str)`
|
144
|
+
|
145
|
+
* `assert_column_starts_with(col_number, expected_text)`
|
146
|
+
|
147
|
+
* `assert_column_ends_with(col_number, expected_text)`
|
148
|
+
|
149
|
+
* `assert_column_regexp(col_number, regexp_str)`
|
150
|
+
|
151
|
+
* `assert_columns_each_match_regexp(col_start, col_end, regexp_str)`
|
152
|
+
|
153
|
+
#### Cursor Assertions
|
154
|
+
|
131
155
|
* `assert_cursor_position(x: x, y: y)`
|
132
156
|
|
133
157
|
* `assert_cursor_visible`
|
134
158
|
|
135
159
|
* `assert_cursor_hidden`
|
136
160
|
|
161
|
+
#### Screen Contents Assertions
|
162
|
+
|
137
163
|
* `assert_contents(lines_of_terminal)`
|
138
164
|
|
139
165
|
* `assert_contents_at(row_start, row_end, expected_text)`
|
@@ -144,6 +170,8 @@ If you are reading this on github, the ruby docs accessible from [RubyDoc.Info](
|
|
144
170
|
|
145
171
|
* `assert_contents_match_regexp(regexp_str)`
|
146
172
|
|
173
|
+
#### File Assertions
|
174
|
+
|
147
175
|
* `assert_file_exists(file_path)`
|
148
176
|
|
149
177
|
* `assert_file_doesnt_exist(file_path)`
|
@@ -162,17 +190,17 @@ Note: Most of the time send_line has the best ergonomics.
|
|
162
190
|
|
163
191
|
### Base Functions
|
164
192
|
|
165
|
-
These functions form the basis of interacting with the tmux pane.
|
193
|
+
These functions form the basis of interacting with the tmux pane. Internally they power the other functions, but you can also use them directly.
|
166
194
|
|
167
|
-
* `send_keys(output)`: for canonical
|
195
|
+
* `send_keys(output)`: for canonical apps (or multi-character keys for noncanonical apps).
|
168
196
|
|
169
|
-
* `send_keys_one_at_a_time(output)`: for noncanonical
|
197
|
+
* `send_keys_one_at_a_time(output)`: for noncanonical apps.
|
170
198
|
|
171
|
-
* `send_keys_exact(output)`: sends keys as is, exactly. Also useful for sending tmux specific keys (any
|
199
|
+
* `send_keys_exact(output)`: sends keys as is, exactly. Also useful for sending tmux specific keys (any tmux send-keys arguments like: DC (delete), Escape (ESC), etc.)
|
172
200
|
|
173
201
|
### Ergonomic Functions
|
174
202
|
|
175
|
-
The base functions work great, but these functions build upon the base functions to provide more
|
203
|
+
The base functions work great, but these functions build upon the base functions to provide more functionalities and better ergonomics.
|
176
204
|
|
177
205
|
For example, `send_line(line)` makes sure that the enter key (newline character) is sent after the `line` so you don't have to worry about adding it to `line` or calling send_newline after.
|
178
206
|
|
@@ -188,8 +216,14 @@ For example, `send_line(line)` makes sure that the enter key (newline character)
|
|
188
216
|
|
189
217
|
* `send_line_exact`: send line exactly as is to tmux. Certain special characters may not work with send_line. You can also include tmux send-keys arguments like DC for delete, etc.
|
190
218
|
|
219
|
+
* `send_line_exact_then_sleep(line, sleep_time)`: simulate typing in a command in the terminal and hitting enter using send_line_exact semantics, then wait for sleep_time seconds.
|
220
|
+
|
191
221
|
* `send_lines_exact`: send lines exactly are they are to tmux. Similar semantics to send_line_exact.
|
192
222
|
|
223
|
+
* `send_lines_exact_then_sleep(lines, sleep_time)`: for each line in lines, simulate sending the line and hitting enter using send_line_exact semantics. After sending all the lines, sleep for sleep_time.
|
224
|
+
|
225
|
+
* `send_line_exact_then_sleep_and_repeat(lines, sleep_time)`: for each line in lines, simulate sending the line and hitting enter using send_line_exact, then sleep before sending the next line.
|
226
|
+
|
193
227
|
### Output Helpers
|
194
228
|
|
195
229
|
Helper functions to make sending output easier! They use the methods above under 'Sending Output' section under the hood.
|
@@ -200,7 +234,6 @@ Helper functions to make sending output easier! They use the methods above under
|
|
200
234
|
* `send_return` # simulate hitting enter, equivalent to @tty.send_keys(%(\r))
|
201
235
|
* `send_returns(number_of_times)` # equivalent to calling send_return number_of_times
|
202
236
|
|
203
|
-
|
204
237
|
* `send_backspace` # simulate hitting backspace, equivalent to @tty.send_keys(TTYtest::BACKSPACE)
|
205
238
|
* `send_backspaces(number_of_times)` # equivalent to calling send_backspace number_of_times
|
206
239
|
|
@@ -246,9 +279,12 @@ Send F keys like F1, F2, etc. as shown below:
|
|
246
279
|
|
247
280
|
### Constants
|
248
281
|
|
249
|
-
|
282
|
+
Commonly used keys are available as constants to simplify use.
|
250
283
|
|
251
284
|
``` ruby
|
285
|
+
# can use like:
|
286
|
+
send_keys_exact(TTYtest::CTRLA)
|
287
|
+
|
252
288
|
TTYtest::CTRLA
|
253
289
|
TTYtest::CTRLB
|
254
290
|
TTYtest::CTRLC
|
@@ -287,7 +323,7 @@ There are 2 main configurations for ttytest2: max_wait_time, and use_return_for_
|
|
287
323
|
|
288
324
|
### Max wait time
|
289
325
|
|
290
|
-
Max wait time represents the amount of time in seconds that ttytest2 will keep retrying an assertion before failing.
|
326
|
+
Max wait time represents the amount of time in seconds that ttytest2 will keep retrying an assertion before failing that assertion.
|
291
327
|
|
292
328
|
You can configure max wait time as shown below.
|
293
329
|
|
@@ -301,7 +337,7 @@ You can configure max wait time as shown below.
|
|
301
337
|
|
302
338
|
### Use return for newline
|
303
339
|
|
304
|
-
Use return for newline tells ttytest2 to use return ('
|
340
|
+
Use return for newline tells ttytest2 to use return ('/r') instead of newline ('/n') for methods like send_line, send_line_exact, etc.
|
305
341
|
|
306
342
|
Some line readers may interpreter return and newline differently, so this can be useful in those cases.
|
307
343
|
|
@@ -346,11 +382,11 @@ p "\n#{@tty.capture}" # this is equivalent to above statement @tty.print
|
|
346
382
|
|
347
383
|
## Tips
|
348
384
|
|
349
|
-
If you are using ttyest2 to test your CLI, using sh
|
385
|
+
If you are using ttyest2 to test your CLI, using sh can be easier than bash because you don't have to worry about user, current working directory, etc. as shown in the examples.
|
350
386
|
|
351
|
-
|
387
|
+
The assertions like `assert_row_like`, `assert_row_starts_with`, and `assert_row_ends_with` are usually extremely helpful, especially if trying to test your application in different environments or using a docker container with a shell that is not sh.
|
352
388
|
|
353
|
-
Most line readers use '\n' for newline, but some may interpret
|
389
|
+
Most line readers use '\n' for newline, but some may interpret newline and return differently or expect '\r' for the enter key.
|
354
390
|
|
355
391
|
## Docker
|
356
392
|
|
@@ -37,5 +37,132 @@ module TTYtest
|
|
37
37
|
"expected column #{col_number} to be empty\nEntire screen:\n#{self}"
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
# Asserts the contents of a column contain the expected string at the specified position
|
42
|
+
# @param [Integer] col_number the column (starting from 0) to test against
|
43
|
+
# @param [Integer] row_start the row position to start comparing expected against
|
44
|
+
# @param [Integer] row_end the row position to end comparing expected against (inclusive)
|
45
|
+
# @param [String] expected the expected value that the column starts with. Any trailing whitespace is ignored
|
46
|
+
# @raise [MatchError] if the column doesn't match
|
47
|
+
def assert_column_at(col_number, row_start, row_end, expected)
|
48
|
+
validate(col_number)
|
49
|
+
expected = expected.rstrip
|
50
|
+
actual = []
|
51
|
+
|
52
|
+
rows.each_with_index do |row, i|
|
53
|
+
next if i < row_start
|
54
|
+
break if i > row_end || row.nil?
|
55
|
+
|
56
|
+
actual[i - row_start] = row[col_number]
|
57
|
+
next if row[col_number] == expected[i - row_start]
|
58
|
+
|
59
|
+
raise MatchError,
|
60
|
+
"expected column #{col_number} to be #{expected.inspect}\n
|
61
|
+
Entire screen:\n#{self}"
|
62
|
+
end
|
63
|
+
|
64
|
+
return if !actual.nil? && actual.join.eql?(expected)
|
65
|
+
|
66
|
+
inspection = get_inspection(actual.join)
|
67
|
+
|
68
|
+
raise MatchError,
|
69
|
+
"expected column #{col_number} to contain #{expected} at #{row_start}-#{row_end} and got #{inspection}\nEntire screen:\n#{self}"
|
70
|
+
end
|
71
|
+
|
72
|
+
# Asserts the contents of a single column contains the value expected
|
73
|
+
# @param [Integer] col_number the column number (starting from 0) to test against
|
74
|
+
# @param [String] expected the expected value contained in the column. Any trailing whitespace is ignored
|
75
|
+
# @raise [MatchError] if the column doesn't match
|
76
|
+
def assert_column_like(col_number, expected)
|
77
|
+
validate(col_number)
|
78
|
+
expected = expected.rstrip
|
79
|
+
actual = get_column(col_number).join
|
80
|
+
|
81
|
+
return if !actual.nil? && actual.include?(expected)
|
82
|
+
|
83
|
+
raise MatchError,
|
84
|
+
"expected column #{col_number} to be like #{expected.inspect} but got #{get_inspection(actual)}\nEntire screen:\n#{self}"
|
85
|
+
end
|
86
|
+
alias assert_column_contains assert_column_like
|
87
|
+
|
88
|
+
# Asserts the contents of a single column starts with expected string
|
89
|
+
# @param [Integer] col_number the column (starting from 0) to test against
|
90
|
+
# @param [String] expected the expected value that the column starts with. Any trailing whitespace is ignored
|
91
|
+
# @raise [MatchError] if the column doesn't match
|
92
|
+
def assert_column_starts_with(col_number, expected)
|
93
|
+
validate(col_number)
|
94
|
+
expected = expected.rstrip
|
95
|
+
actual = get_column(col_number).join
|
96
|
+
|
97
|
+
return if !actual.nil? && actual.start_with?(expected)
|
98
|
+
|
99
|
+
raise MatchError,
|
100
|
+
"expected column #{col_number} to start with #{expected.inspect} and got #{get_inspection(actual)}\nEntire screen:\n#{self}"
|
101
|
+
end
|
102
|
+
|
103
|
+
# Asserts the contents of a column ends with expected
|
104
|
+
# @param [Integer] col_number the column (starting from 0) to test against
|
105
|
+
# @param [String] expected the expected value that the column starts with. Any trailing whitespace is ignored
|
106
|
+
# @raise [MatchError] if the column doesn't match
|
107
|
+
def assert_column_ends_with(col_number, expected)
|
108
|
+
validate(col_number)
|
109
|
+
expected = expected.rstrip
|
110
|
+
actual = get_column(col_number).join
|
111
|
+
|
112
|
+
return if !actual.nil? && actual.end_with?(expected)
|
113
|
+
|
114
|
+
raise MatchError,
|
115
|
+
"expected column #{col_number} to end with #{expected.inspect} and got #{get_inspection(actual)}\nEntire screen:\n#{self}"
|
116
|
+
end
|
117
|
+
|
118
|
+
# Asserts the contents of a single column match against the passed in regular expression
|
119
|
+
# @param [Integer] col_number the column (starting from 0) to test against
|
120
|
+
# @param [String] regexp_str the regular expression as a string that will be used to match with.
|
121
|
+
# @raise [MatchError] if the column doesn't match against the regular expression
|
122
|
+
def assert_column_regexp(col_number, regexp_str)
|
123
|
+
validate(col_number)
|
124
|
+
regexp = Regexp.new(regexp_str)
|
125
|
+
actual = get_column(col_number).join
|
126
|
+
|
127
|
+
return if !actual.nil? && actual.match?(regexp)
|
128
|
+
|
129
|
+
raise MatchError,
|
130
|
+
"expected column #{col_number} to match regexp #{regexp_str} but it did not. Column value #{get_inspection(actual)}\nEntire screen:\n#{self}"
|
131
|
+
end
|
132
|
+
|
133
|
+
# Asserts the contents of a multiple columns each match against the passed in regular expression
|
134
|
+
# @param [Integer] col_start the column (starting from 0) to test against
|
135
|
+
# @param [Integer] col_end the last column to test against
|
136
|
+
# @param [String] regexp_str the regular expression as a string that will be used to match with.
|
137
|
+
# @raise [MatchError] if the column doesn't match against the regular expression
|
138
|
+
def assert_columns_each_match_regexp(col_start, col_end, regexp_str)
|
139
|
+
validate(col_end)
|
140
|
+
regexp = Regexp.new(regexp_str)
|
141
|
+
col_cur = col_start
|
142
|
+
col_end += 1 if col_end.zero?
|
143
|
+
|
144
|
+
while col_cur < col_end
|
145
|
+
actual = get_column(col_cur).join
|
146
|
+
col_cur += 1
|
147
|
+
next if !actual.nil? && actual.match?(regexp)
|
148
|
+
|
149
|
+
raise MatchError,
|
150
|
+
"expected column #{col_cur - 1} to match regexp #{regexp_str} but it did not. Column value #{get_inspection(actual)}\nEntire screen:\n#{self}"
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
private
|
155
|
+
|
156
|
+
def get_column(col_number)
|
157
|
+
actual = []
|
158
|
+
|
159
|
+
rows.each_with_index do |row, i|
|
160
|
+
break if row.nil?
|
161
|
+
|
162
|
+
actual[i] = row[col_number]
|
163
|
+
end
|
164
|
+
|
165
|
+
actual
|
166
|
+
end
|
40
167
|
end
|
41
168
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TTYtest
|
4
|
+
# Exit Code Assertions for ttytest2. Not finished and added yet.
|
5
|
+
module ExitCodeAssertions
|
6
|
+
# Asserts that the exit code of the previous command matches the specified value
|
7
|
+
# Note: if you are tracking current row in your tests, this command will take up 2 lines.
|
8
|
+
# It echos the previous commands exit code to the screen and then reads it from there
|
9
|
+
# @param [Integer] code the expected exit code
|
10
|
+
# @raise [MatchError] if the exit code found does not match specified value
|
11
|
+
def assert_exit_code(code) end
|
12
|
+
end
|
13
|
+
end
|
@@ -61,7 +61,7 @@ module TTYtest
|
|
61
61
|
|
62
62
|
# Asserts the specified file has line count specified
|
63
63
|
# @param [String] file_path the path to the file
|
64
|
-
# @param [
|
64
|
+
# @param [Integer] expected_count the expected line count of the file
|
65
65
|
# @raise [MatchError] if the file has a different line count than specified
|
66
66
|
def assert_file_has_line_count(file_path, expected_count)
|
67
67
|
raise file_not_found_error(file_path) unless File.exist?(file_path)
|
@@ -34,7 +34,7 @@ module TTYtest
|
|
34
34
|
end
|
35
35
|
alias assert_line_is_empty assert_row_is_empty
|
36
36
|
|
37
|
-
# Asserts the contents of a
|
37
|
+
# Asserts the contents of a row contain the expected string at the specified position
|
38
38
|
# @param [Integer] row_number the row (starting from 0) to test against
|
39
39
|
# @param [Integer] column_start the column position to start comparing expected against
|
40
40
|
# @param [Integer] columns_end the column position to end comparing expected against
|
@@ -51,8 +51,7 @@ module TTYtest
|
|
51
51
|
inspection = get_inspection_bounded(actual, column_start, column_end)
|
52
52
|
|
53
53
|
raise MatchError,
|
54
|
-
"expected row #{row_number} to contain #{expected
|
55
|
-
column_end]} at #{column_start}-#{column_end} and got #{inspection}\nEntire screen:\n#{self}"
|
54
|
+
"expected row #{row_number} to contain #{expected} at #{column_start}-#{column_end} and got #{inspection}\nEntire screen:\n#{self}"
|
56
55
|
end
|
57
56
|
alias assert_line_at assert_row_at
|
58
57
|
|
@@ -90,7 +89,7 @@ module TTYtest
|
|
90
89
|
end
|
91
90
|
alias assert_line_starts_with assert_row_starts_with
|
92
91
|
|
93
|
-
# Asserts the contents of a single row
|
92
|
+
# Asserts the contents of a single row ends with expected
|
94
93
|
# @param [Integer] row_number the row (starting from 0) to test against
|
95
94
|
# @param [String] expected the expected value that the row starts with. Any trailing whitespace is ignored
|
96
95
|
# @raise [MatchError] if the row doesn't match
|
data/lib/ttytest/tmux/session.rb
CHANGED
@@ -78,6 +78,19 @@ module TTYtest
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
def send_lines_then_sleep(*lines, sleep_time)
|
82
|
+
lines.each do |line|
|
83
|
+
send_line(line)
|
84
|
+
end
|
85
|
+
sleep sleep_time
|
86
|
+
end
|
87
|
+
|
88
|
+
def send_line_then_sleep_and_repeat(*lines, sleep_time)
|
89
|
+
lines.each do |line|
|
90
|
+
send_line_then_sleep(line, sleep_time)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
81
94
|
def send_line_exact(line)
|
82
95
|
send_keys_exact(line)
|
83
96
|
if @use_return_for_newline
|
@@ -87,22 +100,28 @@ module TTYtest
|
|
87
100
|
send_newline unless line[-1] == '\n'
|
88
101
|
end
|
89
102
|
|
103
|
+
# Send line then sleep for sleep_time
|
104
|
+
def send_line_exact_then_sleep(line, sleep_time)
|
105
|
+
send_line_exact(line)
|
106
|
+
sleep sleep_time
|
107
|
+
end
|
108
|
+
|
90
109
|
def send_lines_exact(*lines)
|
91
110
|
lines.each do |line|
|
92
111
|
send_line_exact(line)
|
93
112
|
end
|
94
113
|
end
|
95
114
|
|
96
|
-
def
|
115
|
+
def send_lines_exact_then_sleep(*lines, sleep_time)
|
97
116
|
lines.each do |line|
|
98
|
-
|
117
|
+
send_line_exact(line)
|
99
118
|
end
|
100
119
|
sleep sleep_time
|
101
120
|
end
|
102
121
|
|
103
|
-
def
|
122
|
+
def send_line_exact_then_sleep_and_repeat(*lines, sleep_time)
|
104
123
|
lines.each do |line|
|
105
|
-
|
124
|
+
send_line_exact_then_sleep(line, sleep_time)
|
106
125
|
end
|
107
126
|
end
|
108
127
|
|
data/lib/ttytest/version.rb
CHANGED
data/lib/ttytest.rb
CHANGED
@@ -22,12 +22,12 @@ module TTYtest
|
|
22
22
|
|
23
23
|
# @!method new_default_sh_terminal
|
24
24
|
# Create a new terminal using '/bin/sh' with width: 80 and height: 24.
|
25
|
-
# Useful for
|
25
|
+
# Useful for applications like shells which may show user or the cwd.
|
26
26
|
# @return [Terminal] a new sh terminal
|
27
27
|
|
28
28
|
# @!method new_sh_terminal(width: 80, height: 24)
|
29
29
|
# Create a new terminal using '/bin/sh' with ability to set width and height.
|
30
|
-
# Useful for
|
30
|
+
# Useful for applications like shells which may show user or the cwd.
|
31
31
|
# @param [Integer] max_wait_time max time to wait for screen to update before an assertion fails
|
32
32
|
# @param [bool] use_return_for_newline use return instead of newline for functions like send_line
|
33
33
|
# @return [Terminal] a new sh terminal with specified width and height
|
@@ -35,8 +35,6 @@ module TTYtest
|
|
35
35
|
def_delegators :driver
|
36
36
|
|
37
37
|
def new_terminal(cmd, width: 80, height: 24, max_wait_time: 2, use_return_for_newline: false)
|
38
|
-
# @max_wait_time = max_wait_time
|
39
|
-
# @use_return_for_newline = use_return_for_newline
|
40
38
|
driver.new_terminal(cmd, width: width, height: height, max_wait_time: max_wait_time,
|
41
39
|
use_return_for_newline: use_return_for_newline)
|
42
40
|
end
|
data/notes.txt
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ttytest2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Eski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- ".github/workflows/test.yml"
|
93
93
|
- ".gitignore"
|
94
94
|
- Gemfile
|
95
|
+
- LICENSE
|
95
96
|
- README.md
|
96
97
|
- Rakefile
|
97
98
|
- examples/integration_tests.rb
|
@@ -100,6 +101,7 @@ files:
|
|
100
101
|
- lib/ttytest/assertions.rb
|
101
102
|
- lib/ttytest/assertions/column_assertions.rb
|
102
103
|
- lib/ttytest/assertions/cursor_assertions.rb
|
104
|
+
- lib/ttytest/assertions/exit_code_assertions.rb
|
103
105
|
- lib/ttytest/assertions/file_assertions.rb
|
104
106
|
- lib/ttytest/assertions/row_assertions.rb
|
105
107
|
- lib/ttytest/assertions/screen_assertions.rb
|