ttytest2 0.9.13 → 1.0.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/.bundle/config +0 -0
- data/.github/workflows/test.yml +0 -0
- data/.gitignore +0 -0
- data/Gemfile +0 -0
- data/README.md +21 -2
- data/Rakefile +0 -0
- data/examples/integration_tests.rb +0 -0
- data/lib/ttytest/capture.rb +0 -0
- data/lib/ttytest/constants.rb +0 -0
- data/lib/ttytest/matchers.rb +0 -0
- data/lib/ttytest/terminal.rb +0 -0
- data/lib/ttytest/tmux/driver.rb +8 -0
- data/lib/ttytest/tmux/session.rb +2 -2
- data/lib/ttytest/tmux/tmux.conf +0 -0
- data/lib/ttytest/version.rb +1 -1
- data/lib/ttytest.rb +9 -1
- data/notes.txt +2 -2
- data/ttytest2.gemspec +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4322aa40df769e1ed8a2095f5766199175afae71233c8308b3a6ef30322fedb2
|
4
|
+
data.tar.gz: 3d94b40f20cbea852a6462d23d3922a6a1e7ef95573815320047279f47e8c76d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90580621915fddc1ba3b6390fc58e7787fdfa86336cb576abd3224a68c8cb88fbf665425d960153bd0cf4d170aa02afb63f14f53acc2f1f37711d8bbb0c244a1
|
7
|
+
data.tar.gz: 44047668527313f4bcea17522d2c8ee77bf9e0695ebd89a6c68a01411305cd3389eb5e22e43c1c4861662414b7721b6772fd26d84b1364a8a447d9363af0ab04
|
data/.bundle/config
CHANGED
File without changes
|
data/.github/workflows/test.yml
CHANGED
File without changes
|
data/.gitignore
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ ttytest2 is a fork and a drop-in replacement for [ttytest](https://github.com/jh
|
|
6
6
|
|
7
7
|
It works by running commands inside a tmux session, capturing the pane, and comparing the content to your assertions.
|
8
8
|
|
9
|
-
The assertions will wait a specified amount of time (default 2 seconds) for the expected content to appear.
|
9
|
+
The assertions will wait a specified amount of time (configurable, default 2 seconds) for the expected content to appear.
|
10
10
|
|
11
11
|
[](https://badge.fury.io/rb/ttytest2)
|
12
12
|
|
@@ -77,15 +77,25 @@ Assertions will be retried for up to 2 seconds when called through TTYtest::Term
|
|
77
77
|
Available assertions:
|
78
78
|
|
79
79
|
* `assert_row(row_number, expected_text)`
|
80
|
+
|
80
81
|
* `assert_row_at(row_number, column_start_position, column_end_position, expected_text)`
|
82
|
+
|
81
83
|
* `assert_row_like(row_number, expected_text)`
|
84
|
+
|
82
85
|
* `assert_row_starts_with(row_number, expected_text)`
|
86
|
+
|
83
87
|
* `assert_row_ends_with(row_number, expected_text)`
|
88
|
+
|
84
89
|
* `assert_row_regexp(row_number, regexp_str)`
|
90
|
+
|
85
91
|
* `assert_cursor_position(x: x, y: y)`
|
92
|
+
|
86
93
|
* `assert_cursor_visible`
|
94
|
+
|
87
95
|
* `assert_cursor_hidden`
|
96
|
+
|
88
97
|
* `assert_contents(lines_of_terminal)`
|
98
|
+
|
89
99
|
* `assert_contents_at(row_start, row_end, expected_text)`
|
90
100
|
|
91
101
|
### Output
|
@@ -118,21 +128,30 @@ Helper functions to make sending output easier! They use the methods above under
|
|
118
128
|
* `send_newlines(number_of_times)` # equivalent to calling send_newline number_of_times
|
119
129
|
* `send_enter` # alias for send_newline
|
120
130
|
* `send_enters(number_of_times)` # alias for send_newlines
|
131
|
+
|
121
132
|
* `send_backspace` # simulate hitting backspace, equivalent to @tty.send_keys(TTYtest::BACKSPACE)
|
122
133
|
* `send_backspaces(number_of_times)` # equivalent to calling send_backspace number_of_times
|
134
|
+
|
123
135
|
* `send_delete` # simulate hitting delete, equivalent to calling send_keys_exact(%(DC))
|
124
136
|
* `send_deletes` # equivalent to calling send_delete number_of_times
|
137
|
+
|
125
138
|
* `send_right_arrow`
|
126
139
|
* `send_right_arrows(number_of_times)`
|
140
|
+
|
127
141
|
* `send_left_arrow`
|
128
142
|
* `send_left_arrows(number_of_times)`
|
143
|
+
|
129
144
|
* `send_up_arrow`
|
130
145
|
* `send_up_arrows(number_of_times)`
|
146
|
+
|
131
147
|
* `send_down_arrow`
|
132
148
|
* `send_down_arrows(number_of_times)`
|
149
|
+
|
133
150
|
* `send_home` # simulate pressing the Home key
|
134
151
|
* `send_end` # simulate pressing the End key
|
152
|
+
|
135
153
|
* `send_clear` # clear the screen by sending clear ascii code
|
154
|
+
|
136
155
|
* `send_escape`
|
137
156
|
* `send_escapes`
|
138
157
|
|
@@ -227,7 +246,7 @@ There are some commonly used keys available as constants to make interacting wit
|
|
227
246
|
TTYtest::CLEAR # clear the screen
|
228
247
|
```
|
229
248
|
|
230
|
-
|
249
|
+
## Tips
|
231
250
|
|
232
251
|
If you are using ttyest2 to test your CLI, using sh is easier than bash because you don't have to worry about user, current working directory, etc. as shown in the examples.
|
233
252
|
|
data/Rakefile
CHANGED
File without changes
|
File without changes
|
data/lib/ttytest/capture.rb
CHANGED
File without changes
|
data/lib/ttytest/constants.rb
CHANGED
File without changes
|
data/lib/ttytest/matchers.rb
CHANGED
File without changes
|
data/lib/ttytest/terminal.rb
CHANGED
File without changes
|
data/lib/ttytest/tmux/driver.rb
CHANGED
@@ -39,6 +39,14 @@ module TTYtest
|
|
39
39
|
Terminal.new(session)
|
40
40
|
end
|
41
41
|
|
42
|
+
def new_default_sh_terminal
|
43
|
+
new_terminal(%(PS1='$ ' /bin/sh), width: 80, height: 24)
|
44
|
+
end
|
45
|
+
|
46
|
+
def new_sh_terminal(width: 80, height: 24)
|
47
|
+
new_terminal(%(PS1='$ ' /bin/sh), width: width, height: height)
|
48
|
+
end
|
49
|
+
|
42
50
|
# @api private
|
43
51
|
def tmux(*args)
|
44
52
|
ensure_available
|
data/lib/ttytest/tmux/session.rb
CHANGED
@@ -80,9 +80,9 @@ module TTYtest
|
|
80
80
|
sleep sleep_time
|
81
81
|
end
|
82
82
|
|
83
|
-
def send_line_then_sleep_and_repeat(*lines)
|
83
|
+
def send_line_then_sleep_and_repeat(*lines, sleep_time)
|
84
84
|
lines.each do |line|
|
85
|
-
send_line_then_sleep(line)
|
85
|
+
send_line_then_sleep(line, sleep_time)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
data/lib/ttytest/tmux/tmux.conf
CHANGED
File without changes
|
data/lib/ttytest/version.rb
CHANGED
data/lib/ttytest.rb
CHANGED
@@ -17,7 +17,15 @@ module TTYtest
|
|
17
17
|
# @param [Integer] width width of the new terminal
|
18
18
|
# @param [Integer] height height of the new terminal
|
19
19
|
# @return [Terminal] a new terminal running the specified command
|
20
|
-
|
20
|
+
|
21
|
+
# @!method new_default_sh_terminal
|
22
|
+
# Create a new terminal using '/bin/sh' with width: 80 and height: 24.
|
23
|
+
# Useful for Unixes.
|
24
|
+
|
25
|
+
# @!method new_sh_terminal(width: 80, height: 24)
|
26
|
+
# Create a new terminal using '/bin/sh' with ability to set width and height.
|
27
|
+
# Useful for Unixes.
|
28
|
+
def_delegators :driver, :new_terminal, :new_default_sh_terminal, :new_sh_terminal
|
21
29
|
end
|
22
30
|
|
23
31
|
class MatchError < StandardError; end
|
data/notes.txt
CHANGED
data/ttytest2.gemspec
CHANGED
File without changes
|
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: 0.
|
4
|
+
version: 1.0.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-02-
|
11
|
+
date: 2025-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|