ttytest2 0.8.4 → 0.8.5
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 +39 -3
- data/lib/ttytest/constants.rb +5 -6
- data/lib/ttytest/terminal.rb +1 -1
- data/lib/ttytest/tmux/session.rb +4 -0
- 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: 3b98c6cd8789c970147b325d01c3af8e4b4eef8f32bac57aae4036b8ce3586d9
|
4
|
+
data.tar.gz: ddbfe244faedd701d96bc98ce103b49a8d825517e0664dbbea858954319290b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4862a535e862eb7fa58bc3373306ee3f82b939f5652b9b334e55acb5437358159cef2dd02d551823ff47e62625ac3b69200c526365fee2277882a617156acbd
|
7
|
+
data.tar.gz: 7ceed490dc0fb92b77ace530650a92691fdc69fa1833344b8e0000d5b1f21fe654d995b63825b5512d289c75079a83abc117d0e24c85483fda7efc5bf634bda2
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# ttytest2
|
2
2
|
|
3
|
-
|
3
|
+
ttytest2 is an acceptance test framework for interactive console applications. It's like [capybara](https://github.com/teamcapybara/capybara) for the terminal.
|
4
4
|
|
5
|
-
|
5
|
+
A drop-in replacement for https://github.com/jhawthorn/ttytest, because I had some features I needed for my own project.
|
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
|
|
@@ -29,8 +29,16 @@ Available assertions:
|
|
29
29
|
* `assert_cursor_hidden`
|
30
30
|
* `assert_contents(lines_of_terminal)`
|
31
31
|
|
32
|
+
### Sending output
|
33
|
+
|
34
|
+
You can send output to the terminal with the following calls.
|
35
|
+
|
36
|
+
* `send_keys(output)`
|
37
|
+
* `send_newline # equivalent to @tty.send_keys(%(\n))`
|
38
|
+
* `send_keys_one_at_a_time(output)`
|
32
39
|
|
33
40
|
### Example Canonical CLI/Shell
|
41
|
+
|
34
42
|
Most people should use send_keys, if you are writing or working with a noncanonical shell/CLI, you will probably know it. Most are canonical.
|
35
43
|
|
36
44
|
``` ruby
|
@@ -53,7 +61,10 @@ p @tty.rows # => ["$ echo \"Hello, world\"", "Hello, world", "$", "", "", "", ..
|
|
53
61
|
```
|
54
62
|
|
55
63
|
### Example Noncanonical CLI/Shell
|
56
|
-
|
64
|
+
|
65
|
+
If you are working with a noncanonical shell, you need to use send_keys_one_at_a_time to have your shell/CLI process the input correctly.<br /><br />
|
66
|
+
Also useful if you need to send input one character at a time for whatever reason.<br /><br />
|
67
|
+
'Multi-character' characters like '\n' need to be sent with send-keys, though.<br /><br />
|
57
68
|
|
58
69
|
``` ruby
|
59
70
|
require 'ttytest'
|
@@ -65,6 +76,31 @@ require 'ttytest'
|
|
65
76
|
@tty.send_keys_one_at_a_time('ls')
|
66
77
|
@tty.assert_row_ends_with(0, 'ls')
|
67
78
|
@tty.send_keys(%(\n)) # make sure to use send_keys for 'multi-character' characters like \n, \r, \t, etc.
|
79
|
+
|
80
|
+
@tty.send_keys_one_at_a_time('ps')
|
81
|
+
@tty.assert_row_ends_with(0, 'ps')
|
82
|
+
@tty.send_keys(TTYtest:NEWLINE) # can use constants instead
|
83
|
+
```
|
84
|
+
|
85
|
+
### Constants
|
86
|
+
|
87
|
+
There are some commonly used keys available as constants to make interacting with your shell/CLI easy. Most of them are self-evident, BACKSPACE is the same as hitting the backspace key on the keyboard.
|
88
|
+
|
89
|
+
``` ruby
|
90
|
+
TTYtest::BACKSPACE
|
91
|
+
TTYtest::DELETE
|
92
|
+
TTYtest::TAB
|
93
|
+
TTYtest::CTRLF
|
94
|
+
TTYtest::CTRLC
|
95
|
+
TTYtest::CTRLD
|
96
|
+
TTYtest::ESCAPE
|
97
|
+
|
98
|
+
TTYtest::UP_ARROW
|
99
|
+
TTYtest::DOWN_ARROW
|
100
|
+
TTYtest::RIGHT_ARROW
|
101
|
+
TTYtest::LEFT_ARROW
|
102
|
+
|
103
|
+
TTYtest::CLEAR # clear the screen
|
68
104
|
```
|
69
105
|
|
70
106
|
## Docker
|
data/lib/ttytest/constants.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# some constants that can be used with send_keys, just to help out people creating tests
|
4
|
-
# may not work with all terminal emulators
|
5
4
|
module TTYtest
|
6
5
|
BACKSPACE = 127.chr
|
6
|
+
DELETE = '^[[3~'
|
7
7
|
TAB = 9.chr
|
8
8
|
CTRLF = 6.chr
|
9
9
|
CTRLC = 3.chr
|
10
10
|
CTRLD = '\004'
|
11
11
|
ESCAPE = 27.chr
|
12
|
-
NEWLINE = '\n'
|
13
12
|
|
14
|
-
UP_ARROW =
|
15
|
-
DOWN_ARROW =
|
16
|
-
RIGHT_ARROW =
|
17
|
-
LEFT_ARROW =
|
13
|
+
UP_ARROW = '^[[A'
|
14
|
+
DOWN_ARROW = '^[[B'
|
15
|
+
RIGHT_ARROW = '^[[C'
|
16
|
+
LEFT_ARROW = '^[[D'
|
18
17
|
|
19
18
|
CLEAR = 'clear'
|
20
19
|
end
|
data/lib/ttytest/terminal.rb
CHANGED
@@ -27,7 +27,7 @@ module TTYtest
|
|
27
27
|
# @!method capture
|
28
28
|
# Capture the current state of the terminal
|
29
29
|
# @return [Capture] instantaneous state of the terminal when called
|
30
|
-
def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :capture
|
30
|
+
def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :send_newline, :capture
|
31
31
|
|
32
32
|
# @!method rows
|
33
33
|
# @return [Array<String>]
|
data/lib/ttytest/tmux/session.rb
CHANGED
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.8.
|
4
|
+
version: 0.8.5
|
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-11-
|
11
|
+
date: 2024-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|