ttytest2 0.9.7 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -4
- data/lib/ttytest/capture.rb +4 -1
- data/lib/ttytest/constants.rb +14 -5
- data/lib/ttytest/terminal.rb +3 -1
- data/lib/ttytest/tmux/session.rb +6 -2
- data/lib/ttytest/version.rb +1 -1
- data/notes.txt +2 -2
- 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: 255274128343764bc7bfcd600e925ba0e84b3c36d79550205890e9583b34723f
|
4
|
+
data.tar.gz: bcfce7f61108dc09ea83baacc27a6dbc2f416fae5b90663859e665887e6d9ed6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9e355e8958e8336e9b76cc976728faf511e1edd3b7cf6774613e3d62c12d93192bb8a1a6f9881d8a63343fdd213050fad6e86e7e37d6cfe20757e3c4f564763
|
7
|
+
data.tar.gz: ff23c17d5fe7b11dd4ca7b0405d647de1e5309c32f9e3f65b98ade66d2aeed5ba5925f959e91af88a2a8e3c0af95e8228592a41af7ead7dc3fe0a8ecc4979e6b
|
data/README.md
CHANGED
@@ -146,11 +146,42 @@ Helper functions to make sending output easier! They use the methods above under
|
|
146
146
|
* `send_end` # simulate pressing the End key
|
147
147
|
* `send_clear` # clear the screen by sending clear ascii code
|
148
148
|
|
149
|
+
### F keys?
|
150
|
+
|
151
|
+
Send F keys like F1, F2, etc. as shown below:
|
152
|
+
|
153
|
+
``` ruby
|
154
|
+
@tty = TTYtest.new_terminal(%{PS1='$ ' /bin/sh}, width: 80, height: 24)
|
155
|
+
|
156
|
+
@tty.send_keys_exact(%(F1))
|
157
|
+
@tty.send_keys_exact(%(F2))
|
158
|
+
# ...
|
159
|
+
@tty.send_keys_exact(%(F11))
|
160
|
+
@tty.send_keys_exact(%(F12))
|
161
|
+
```
|
162
|
+
|
163
|
+
### Configurables
|
164
|
+
|
165
|
+
Currently the only configuration for ttytest2 is max wait time.
|
166
|
+
|
167
|
+
Max wait time represents the amount of time in seconds that ttytest2 will keep retrying an assertion before failing.
|
168
|
+
|
169
|
+
You can configure max wait time as shown below.
|
170
|
+
|
171
|
+
``` ruby
|
172
|
+
@tty = TTYtest::new_terminal('')
|
173
|
+
@tty.max_wait_time = 1 # sets the max wait time to 1 second
|
174
|
+
|
175
|
+
@tty.assert_row(0, 'echo Hello, world') # this assertion would fail after 1 second
|
176
|
+
```
|
177
|
+
|
149
178
|
### Troubleshooting
|
150
179
|
|
151
180
|
You can use the method rows to get all rows of the terminal as an array, of use the method capture to get the contents of the terminal window. This can be useful when troubleshooting.
|
152
181
|
|
153
182
|
``` ruby
|
183
|
+
@tty = TTYtest::new_terminal('')
|
184
|
+
|
154
185
|
# you can use @tty.rows to access the entire pane, split by line into an array.
|
155
186
|
p @tty.rows # prints out the contents of the terminal as a array.
|
156
187
|
@tty.print_rows # equivalent to above, just for ease of use.
|
@@ -165,18 +196,27 @@ p "\n#{@tty.capture}" # prints out the contents of the terminal
|
|
165
196
|
There are some commonly used keys available as constants to make interacting with your shell/CLI easy.
|
166
197
|
|
167
198
|
``` ruby
|
168
|
-
TTYtest::BACKSPACE
|
169
|
-
TTYtest::TAB
|
170
|
-
TTYtest::CTRLF
|
171
199
|
TTYtest::CTRLC
|
172
200
|
TTYtest::CTRLD
|
173
|
-
TTYtest::
|
201
|
+
TTYtest::CTRLF
|
202
|
+
TTYtest::BELL # ring the terminal bell
|
203
|
+
TTYtest::BACKSPACE
|
204
|
+
TTYtest::TAB
|
205
|
+
TTYtest::NEWLINE # \n
|
206
|
+
TTYtest::VERTICAL_TAB
|
207
|
+
TTYtest::FORM_FEED # \f or New Page NP
|
208
|
+
TTYtest::CARRIAGE_RETURN # \r
|
209
|
+
TTYtest::ESCAPE # 27 decimal or ^[ or /033
|
210
|
+
TTYtest::DELETE
|
174
211
|
|
175
212
|
TTYtest::UP_ARROW
|
176
213
|
TTYtest::DOWN_ARROW
|
177
214
|
TTYtest::RIGHT_ARROW
|
178
215
|
TTYtest::LEFT_ARROW
|
179
216
|
|
217
|
+
TTYtest::HOME_KEY
|
218
|
+
TTYtest::END_KEY
|
219
|
+
|
180
220
|
TTYtest::CLEAR # clear the screen
|
181
221
|
```
|
182
222
|
|
data/lib/ttytest/capture.rb
CHANGED
data/lib/ttytest/constants.rb
CHANGED
@@ -2,17 +2,26 @@
|
|
2
2
|
|
3
3
|
# some constants that can be used with send_keys, just to help out people creating tests
|
4
4
|
module TTYtest
|
5
|
-
BACKSPACE = 127.chr
|
6
|
-
TAB = 9.chr
|
7
|
-
CTRLF = 6.chr
|
8
5
|
CTRLC = 3.chr
|
9
|
-
CTRLD =
|
10
|
-
|
6
|
+
CTRLD = 4.chr
|
7
|
+
CTRLF = 6.chr
|
8
|
+
BELL = 7.chr
|
9
|
+
BACKSPACE = 8.chr
|
10
|
+
TAB = 9.chr
|
11
|
+
NEWLINE = 10.chr # \n
|
12
|
+
VERTICAL_TAB = 11.chr
|
13
|
+
FORM_FEED = 12.chr
|
14
|
+
CARRIAGE_RETURN = 13.chr # \r
|
15
|
+
ESCAPE = 27.chr # ^[ or /033
|
16
|
+
DELETE = 127.chr
|
11
17
|
|
12
18
|
UP_ARROW = "#{ESCAPE}[A".freeze
|
13
19
|
DOWN_ARROW = "#{ESCAPE}[B".freeze
|
14
20
|
RIGHT_ARROW = "#{ESCAPE}[C".freeze
|
15
21
|
LEFT_ARROW = "#{ESCAPE}[D".freeze
|
16
22
|
|
23
|
+
HOME_KEY = "#{ESCAPE}[H".freeze
|
24
|
+
END_KEY = "#{ESCAPE}[F".freeze
|
25
|
+
|
17
26
|
CLEAR = "#{ESCAPE}[2J".freeze
|
18
27
|
end
|
data/lib/ttytest/terminal.rb
CHANGED
@@ -67,6 +67,8 @@ module TTYtest
|
|
67
67
|
# Simulates typing in the End key in the terminal.
|
68
68
|
# @!method send_clear
|
69
69
|
# Clears the screen in the terminal using ascii clear command.
|
70
|
+
# @!method send_escape
|
71
|
+
# Simulates typing in the Escape (ESC) key in the terminal.
|
70
72
|
# @!method capture
|
71
73
|
# Capture the current state of the terminal
|
72
74
|
# @return [Capture] instantaneous state of the terminal when called
|
@@ -77,7 +79,7 @@ module TTYtest
|
|
77
79
|
:send_backspace, :send_backspaces,
|
78
80
|
:send_left_arrow, :send_left_arrows, :send_right_arrow, :send_right_arrows,
|
79
81
|
:send_down_arrow, :send_down_arrows, :send_up_arrow, :send_up_arrows,
|
80
|
-
:send_keys_exact, :send_home, :send_end, :send_clear,
|
82
|
+
:send_keys_exact, :send_home, :send_end, :send_clear, :send_escape,
|
81
83
|
:capture
|
82
84
|
|
83
85
|
# @!method print
|
data/lib/ttytest/tmux/session.rb
CHANGED
@@ -139,11 +139,11 @@ module TTYtest
|
|
139
139
|
end
|
140
140
|
|
141
141
|
def send_home
|
142
|
-
send_keys_exact(
|
142
|
+
send_keys_exact(TTYtest::HOME_KEY)
|
143
143
|
end
|
144
144
|
|
145
145
|
def send_end
|
146
|
-
send_keys_exact(
|
146
|
+
send_keys_exact(TTYtest::END_KEY)
|
147
147
|
end
|
148
148
|
|
149
149
|
def send_clear
|
@@ -151,6 +151,10 @@ module TTYtest
|
|
151
151
|
send_newline
|
152
152
|
end
|
153
153
|
|
154
|
+
def send_escape
|
155
|
+
send_keys_exact(%(Escape))
|
156
|
+
end
|
157
|
+
|
154
158
|
private
|
155
159
|
|
156
160
|
attr_reader :driver, :name
|
data/lib/ttytest/version.rb
CHANGED
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: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Eski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|