ttytest2 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -32
- data/lib/ttytest/constants.rb +20 -0
- data/lib/ttytest/version.rb +1 -1
- data/lib/ttytest.rb +1 -0
- data/notes.txt +2 -2
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8801fe1b91cd7d371a9b1dc5668ad64b395e80778a6846c21ea004dd635b3107
|
4
|
+
data.tar.gz: fe6847ef687fa1ece179ab5201173145f5ee1b243fa62f533ce5deddc290137a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85b636e54bd9845b50b5d6cc5c9feaa3fac871ee4bf724409f191e38e86649fa695bb6a4917ea877b5d59d6d8dbb2fd0697aacff6122501fba14d6ae56f00654
|
7
|
+
data.tar.gz: 38485e1cae3446068272b40a00d44eb12ce854442c87a8a0dbbd638d9b52a80a82b4c93a10e7f2c83312fef32aa88e771c7fe564d09d8db5e509907e68015bee
|
data/README.md
CHANGED
@@ -6,10 +6,7 @@ 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://badge.fury.io/rb/ttytest2)
|
10
|
-
|
11
|
-
## Gem at RubyGems.org
|
12
|
-
https://rubygems.org/gems/ttytest2
|
9
|
+
[![Gem Version](https://badge.fury.io/rb/ttytest2.svg?icon=si%3Arubygems)](https://badge.fury.io/rb/ttytest2)
|
13
10
|
|
14
11
|
## Minimum Requirements
|
15
12
|
|
@@ -18,6 +15,21 @@ https://rubygems.org/gems/ttytest2
|
|
18
15
|
|
19
16
|
## Usage
|
20
17
|
|
18
|
+
### Assertions
|
19
|
+
|
20
|
+
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).
|
21
|
+
|
22
|
+
Available assertions:
|
23
|
+
* `assert_row(row_number, expected_text)`
|
24
|
+
* `assert_row_like(row_number, expected_text)`
|
25
|
+
* `assert_row_starts_with(row_number, expected_text)`
|
26
|
+
* `assert_row_ends_with(row_number, expected_text)`
|
27
|
+
* `assert_cursor_position(x: x, y: y)`
|
28
|
+
* `assert_cursor_visible`
|
29
|
+
* `assert_cursor_hidden`
|
30
|
+
* `assert_contents(lines_of_terminal)`
|
31
|
+
|
32
|
+
|
21
33
|
### Example Canonical CLI/Shell
|
22
34
|
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.
|
23
35
|
|
@@ -52,23 +64,9 @@ require 'ttytest'
|
|
52
64
|
|
53
65
|
@tty.send_keys_one_at_a_time('ls')
|
54
66
|
@tty.assert_row_ends_with(0, 'ls')
|
55
|
-
@tty.
|
67
|
+
@tty.send_keys(%(\n)) # make sure to use send_keys for 'multi-character' characters like \n, \r, \t, etc.
|
56
68
|
```
|
57
69
|
|
58
|
-
### Assertions
|
59
|
-
|
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).
|
61
|
-
|
62
|
-
Available assertions:
|
63
|
-
* `assert_row(row_number, expected_text)`
|
64
|
-
* `assert_row_like(row_number, expected_text)`
|
65
|
-
* `assert_row_starts_with(row_number, expected_text)`
|
66
|
-
* `assert_row_ends_with(row_number, expected_text)`
|
67
|
-
* `assert_cursor_position(x: x, y: y)`
|
68
|
-
* `assert_cursor_visible`
|
69
|
-
* `assert_cursor_hidden`
|
70
|
-
* `assert_contents(lines_of_terminal)`
|
71
|
-
|
72
70
|
## Docker
|
73
71
|
|
74
72
|
Easy to use from Docker. Add this to your dockerfile to get started.
|
@@ -77,20 +75,9 @@ Easy to use from Docker. Add this to your dockerfile to get started.
|
|
77
75
|
RUN apt update && \
|
78
76
|
apt install gcc make ruby tmux -y && \
|
79
77
|
gem install ttytest2
|
80
|
-
```
|
81
|
-
|
82
|
-
## TravisCI
|
83
|
-
|
84
|
-
TTYtest can run on [TravisCI](https://travis-ci.org/), but the version of tmux made available with their default ubuntu 12.04 environment is too old. However the TravisCI ubuntu 14.04 "trusty" image provides tmux 1.8, which works great.
|
85
|
-
|
86
|
-
Ensure the following is in your `.travis.yml` (see [this project's .travis.yml](./.travis.yml) for an example)
|
87
78
|
|
88
|
-
|
89
|
-
|
90
|
-
addons:
|
91
|
-
apt:
|
92
|
-
packages:
|
93
|
-
- tmux
|
79
|
+
# add this if you have issues
|
80
|
+
# ENV RUBYOPT="-KU -E utf-8:utf-8"
|
94
81
|
```
|
95
82
|
|
96
83
|
## Contributing
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
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
|
+
module TTYtest
|
6
|
+
BACKSPACE = 127.chr
|
7
|
+
TAB = 9.chr
|
8
|
+
CTRLF = 6.chr
|
9
|
+
CTRLC = 3.chr
|
10
|
+
CTRLD = '\004'
|
11
|
+
ESCAPE = 27.chr
|
12
|
+
NEWLINE = '\n'
|
13
|
+
|
14
|
+
UP_ARROW = "#{ESCAPE}[A".freeze
|
15
|
+
DOWN_ARROW = "#{ESCAPE}[B".freeze
|
16
|
+
RIGHT_ARROW = "#{ESCAPE}[C".freeze
|
17
|
+
LEFT_ARROW = "#{ESCAPE}[D".freeze
|
18
|
+
|
19
|
+
CLEAR = 'clear'
|
20
|
+
end
|
data/lib/ttytest/version.rb
CHANGED
data/lib/ttytest.rb
CHANGED
data/notes.txt
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Eski
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- Rakefile
|
82
82
|
- lib/ttytest.rb
|
83
83
|
- lib/ttytest/capture.rb
|
84
|
+
- lib/ttytest/constants.rb
|
84
85
|
- lib/ttytest/matchers.rb
|
85
86
|
- lib/ttytest/terminal.rb
|
86
87
|
- lib/ttytest/tmux/driver.rb
|