ttytest2 0.8.1 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- 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 +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 995f1309860d889b44e0634247e1ae64cda8fc975a8a02de97de55605bd2958e
|
4
|
+
data.tar.gz: a7a2c819970a4a6b432b7067ef3bf2feb8d349332b731df4c1639b4db659140d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83f652b2a5c2815e798cff48d6cd6c83b1a2d325e49306b9f883c11d6a01392c1b0c5303a175b1065238ea01d3628f06cc8a8a96cfa31c42e83d37746cd8cb63
|
7
|
+
data.tar.gz: 3916165f772f1607ab7c03b497848213d30c7e7e93ce584fb911f081c5236d76722e3090b3c2a26889b3c52294e153d66be5df532d45f91a19ce9e0b362b3644
|
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
|
-
[![Gem Version](https://badge.fury.io/rb/ttytest2.svg)](https://
|
9
|
+
[![Gem Version](https://badge.fury.io/rb/ttytest2.svg)](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.split('').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
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.3
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|