ttytest2 0.8.2 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 000e855fe9017a84a4041ff693e8037d7ce134231699fb5e4440be428d7f068b
4
- data.tar.gz: fac1531d712a1f276a3b861fc9f3cb1a21b6a3849433bf4bfff76ec852b39637
3
+ metadata.gz: 8801fe1b91cd7d371a9b1dc5668ad64b395e80778a6846c21ea004dd635b3107
4
+ data.tar.gz: fe6847ef687fa1ece179ab5201173145f5ee1b243fa62f533ce5deddc290137a
5
5
  SHA512:
6
- metadata.gz: 93ee5ba6fad1d8f44f000de98a2acd17fa7cb4d19e96dec87f2ea83a718d95db2eaf59b98d9430f8c4009d6f2808a066da31027d28b6005dd97e1906da16a783
7
- data.tar.gz: 1d9de87f136ae70629a67e21570f325f1cd18e6ce243a0cd000b0f5217efc4222144e52ae1eaa2ba6658d2434c8a3293be83d407adda6e23e6e403432df1f94f
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.send_keys_one_at_a_time(%(\n))
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
- ``` yaml
89
- dist: trusty
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
@@ -42,8 +42,8 @@ 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|
45
+ def send_keys_one_at_a_time(keys)
46
+ keys.split('').each do |key|
47
47
  driver.tmux(*%W[send-keys -t #{name} -l], key)
48
48
  end
49
49
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TTYtest
4
- VERSION = '0.8.2'
4
+ VERSION = '0.8.4'
5
5
  end
data/lib/ttytest.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'forwardable'
4
+ require 'ttytest/constants'
4
5
  require 'ttytest/tmux/driver'
5
6
  require 'ttytest/tmux/session'
6
7
 
data/notes.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  to push new version to github,
2
- git tag v0.8.2
2
+ git tag v0.8.4
3
3
  git push origin --tags
4
4
 
5
5
  to push new version to rubygems.org
6
6
  gem build ttytest2.gemspec
7
- gem push ttytest2-0.8.2.gem
7
+ gem push ttytest2-0.8.4.gem
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.2
4
+ version: 0.8.4
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-13 00:00:00.000000000 Z
11
+ date: 2024-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -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