ttytest2 0.8.1 → 0.8.2
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 +21 -2
- data/Rakefile +2 -0
- data/lib/ttytest/terminal.rb +5 -2
- data/lib/ttytest/tmux/driver.rb +1 -0
- data/lib/ttytest/tmux/session.rb +7 -1
- data/lib/ttytest/version.rb +1 -1
- data/notes.txt +2 -2
- data/ttytest2.gemspec +2 -0
- 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: 000e855fe9017a84a4041ff693e8037d7ce134231699fb5e4440be428d7f068b
|
4
|
+
data.tar.gz: fac1531d712a1f276a3b861fc9f3cb1a21b6a3849433bf4bfff76ec852b39637
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93ee5ba6fad1d8f44f000de98a2acd17fa7cb4d19e96dec87f2ea83a718d95db2eaf59b98d9430f8c4009d6f2808a066da31027d28b6005dd97e1906da16a783
|
7
|
+
data.tar.gz: 1d9de87f136ae70629a67e21570f325f1cd18e6ce243a0cd000b0f5217efc4222144e52ae1eaa2ba6658d2434c8a3293be83d407adda6e23e6e403432df1f94f
|
data/README.md
CHANGED
@@ -6,7 +6,10 @@ 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://
|
9
|
+
[](https://badge.fury.io/rb/ttytest2)
|
10
|
+
|
11
|
+
## Gem at RubyGems.org
|
12
|
+
https://rubygems.org/gems/ttytest2
|
10
13
|
|
11
14
|
## Minimum Requirements
|
12
15
|
|
@@ -15,7 +18,8 @@ It works by running commands inside a tmux session, capturing the pane, and comp
|
|
15
18
|
|
16
19
|
## Usage
|
17
20
|
|
18
|
-
### Example
|
21
|
+
### Example Canonical CLI/Shell
|
22
|
+
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.
|
19
23
|
|
20
24
|
``` ruby
|
21
25
|
require 'ttytest'
|
@@ -36,6 +40,21 @@ TTY
|
|
36
40
|
p @tty.rows # => ["$ echo \"Hello, world\"", "Hello, world", "$", "", "", "", ...]
|
37
41
|
```
|
38
42
|
|
43
|
+
### Example Noncanonical CLI/Shell
|
44
|
+
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.
|
45
|
+
|
46
|
+
``` ruby
|
47
|
+
require 'ttytest'
|
48
|
+
|
49
|
+
@tty = TTYtest.new_terminal(%{PS1='$ ' /bin/noncanonical-sh}, width: 80, height: 24)
|
50
|
+
@tty.assert_row_starts_with(0, ENV['USER'])
|
51
|
+
@tty.assert_row_ends_with(0, '$')
|
52
|
+
|
53
|
+
@tty.send_keys_one_at_a_time('ls')
|
54
|
+
@tty.assert_row_ends_with(0, 'ls')
|
55
|
+
@tty.send_keys_one_at_a_time(%(\n))
|
56
|
+
```
|
57
|
+
|
39
58
|
### Assertions
|
40
59
|
|
41
60
|
The main way to use TTYtest is through assertions. When called on a `TTYtest::Terminal`, each of these will be retried (for up to 2 seconds by default).
|
data/Rakefile
CHANGED
data/lib/ttytest/terminal.rb
CHANGED
@@ -19,12 +19,15 @@ module TTYtest
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# @!method send_keys(*keys)
|
22
|
-
# Simulate typing keys into the terminal
|
22
|
+
# Simulate typing keys into the terminal. For canonical cli's/shells which read line by line.
|
23
|
+
# @param [String] keys keys to send to the terminal
|
24
|
+
# @!method send_keys_one_at_a_time(*keys)
|
25
|
+
# Simulate typing keys into the terminal. For noncanonical cli's/shells which read character by character.
|
23
26
|
# @param [String] keys keys to send to the terminal
|
24
27
|
# @!method capture
|
25
28
|
# Capture the current state of the terminal
|
26
29
|
# @return [Capture] instantaneous state of the terminal when called
|
27
|
-
def_delegators :@driver_terminal, :send_keys, :capture
|
30
|
+
def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :capture
|
28
31
|
|
29
32
|
# @!method rows
|
30
33
|
# @return [Array<String>]
|
data/lib/ttytest/tmux/driver.rb
CHANGED
data/lib/ttytest/tmux/session.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module TTYtest
|
4
4
|
module Tmux
|
5
|
-
# tmux session
|
5
|
+
# represents a tmux session and how to send output to the current tmux session
|
6
6
|
class Session
|
7
7
|
# @api private
|
8
8
|
def initialize(driver, name)
|
@@ -42,6 +42,12 @@ module TTYtest
|
|
42
42
|
driver.tmux(*%W[send-keys -t #{name} -l], *keys)
|
43
43
|
end
|
44
44
|
|
45
|
+
def send_keys_one_at_a_time(*keys)
|
46
|
+
keys.each do |key|
|
47
|
+
driver.tmux(*%W[send-keys -t #{name} -l], key)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
45
51
|
private
|
46
52
|
|
47
53
|
attr_reader :driver, :name
|
data/lib/ttytest/version.rb
CHANGED
data/notes.txt
CHANGED
data/ttytest2.gemspec
CHANGED