ttytest2 0.9.1 → 0.9.2

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: da8ddbaf4a49037e8dda3fb31986824c75819abbee94fb7954263c36a8e63414
4
- data.tar.gz: 7091feb0fdac4857c1c0bf47a7c8158d8c90bd48d1ff321fec53aeab185443ec
3
+ metadata.gz: d96194b301f836b47b4f9ea52632848be70165ac1a772456f64a31289de71064
4
+ data.tar.gz: fb936199069fbcfd35c6579f0cd63387b90634469b1b9789d305775b5995ad71
5
5
  SHA512:
6
- metadata.gz: baab5b496e22d73a133084b2a4d58fc2fb83c95325c02227a50847adcbb876fe23f7a71e80efd69c12c2730aff64866222004db102b21613c4e4301455c15cd8
7
- data.tar.gz: d66c05f581f565f33c9305ec9c484346790184d64ca5bdfb4b9718d95c22b842dbd2f689634548863f93cdcaced2dc94f4048dc66e6101dba8d2ef4f4856bae9
6
+ metadata.gz: c80882c328784d2ddbb94f49928138b8d0393b7e243ceab49defbbd0fe3acea4e7af9c3392ced11115a9ee6ef566bb5c3b71f30b6623c25aac8a5c3cc92881cd
7
+ data.tar.gz: 899589eba988a8e89c19ba47c0cd20285791a00654f44063c9d613f5517dcfedb4d9087230f6e76b058ee7fe7905c4ee30b2f859ba392809be9fbecc5626ba99
data/README.md CHANGED
@@ -15,43 +15,63 @@ It works by running commands inside a tmux session, capturing the pane, and comp
15
15
 
16
16
  ## Usage
17
17
 
18
+ More documentation available at [(https://www.rubydoc.info/gems/ttytest2)].
19
+
18
20
  ### Assertions
19
21
 
20
22
  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
23
 
22
24
  Available assertions:
23
- * specify row matches expected text exactly: `assert_row(row_number, expected_text) `
24
- * specify expected position of expected text: `assert_row_at(row_number, column_start_position, column_end_position, expected_text)`
25
- * specify row contains expected text: `assert_row_like(row_number, expected_text)`
26
- * specify row starts with expected text: `assert_row_starts_with(row_number, expected_text)`
27
- * specify row ends with expected text: `assert_row_ends_with(row_number, expected_text)`
28
- * specify the current cursor position matches expected: `assert_cursor_position(x: x, y: y)`
29
- * specify the cursor is currently visible: `assert_cursor_visible`
30
- * specify the cursor is currently hidden: `assert_cursor_hidden`
31
- * specify the contents of the entire terminal window: `assert_contents(lines_of_terminal)`
25
+ * `assert_row(row_number, expected_text)`
26
+ * `assert_row_at(row_number, column_start_position, column_end_position, expected_text)`
27
+ * `assert_row_like(row_number, expected_text)`
28
+ * `assert_row_starts_with(row_number, expected_text)`
29
+ * `assert_row_ends_with(row_number, expected_text)`
30
+ * `assert_cursor_position(x: x, y: y)`
31
+ * `assert_cursor_visible`
32
+ * `assert_cursor_hidden`
33
+ * `assert_contents(lines_of_terminal)`
32
34
 
33
35
  ### Sending Output
34
36
 
35
37
  You can send output to the terminal with the following calls.
36
38
 
37
- * `send_keys(output) # for canonical shells/cli's (or multi-character keys for noncanonical shells/cli's)`
38
- * `send_keys_one_at_a_time(output) # for noncanonical shells/cli's`
39
+ * `send_keys(output) # for canonical shells/CLI's (or multi-character keys for noncanonical shells/CLI's)`
40
+ * `send_keys_one_at_a_time(output) # for noncanonical shells/CLI's`
39
41
  * `send_keys_exact(output) # for sending tmux specific keys (DC for delete, Escape for ESC, etc.)`
40
42
 
41
43
  ### Output Helpers
42
44
 
43
45
  Helper functions to make sending output easier! They use the methods above under 'Sending Output' section under the hood.
44
46
 
45
- * `send_newline # equivalent to @tty.send_keys(%(\n))`
46
- * `send_newlines(number_of_times) # equivalent to calling send_newline number_of_times`
47
- * `send_backspace # equivalent to @tty.send_keys(TTYtest::BACKSPACE)`
48
- * `send_backspaces(number_of_times) # equivalent to calling send_backspace number_of_times`
49
- * `send_delete # equivalent to calling send_keys_exact(%(DC))`
50
- * `send_deletes # equivalent to calling send_delete number_of_times`
47
+ * `send_newline` # equivalent to @tty.send_keys(%(\n))
48
+ * `send_newlines(number_of_times)` # equivalent to calling send_newline number_of_times
49
+ * `send_backspace` # equivalent to @tty.send_keys(TTYtest::BACKSPACE)
50
+ * `send_backspaces(number_of_times)` # equivalent to calling send_backspace number_of_times
51
+ * `send_delete` # equivalent to calling send_keys_exact(%(DC))
52
+ * `send_deletes` # equivalent to calling send_delete number_of_times
53
+ * `send_right_arrow`
54
+ * `send_right_arrows(number_of_times)`
55
+ * `send_left_arrow`
56
+ * `send_left_arrows(number_of_times)`
57
+ * `send_up_arrow`
58
+ * `send_up_arrows(number_of_times)`
59
+ * `send_down_arrow`
60
+ * `send_down_arrows(number_of_times)`
61
+
62
+ ### Troubleshooting
63
+
64
+ You can use the method rows to get all rows of the terminal as an array, of use the method capture to get the contents of the terminal window. This can be useful when troubleshooting.
65
+
66
+ ``` ruby
67
+ p @tty.rows # prints out the contents of the terminal as a array => ["$ echo \"Hello, world\"", "Hello, world", "$", "", "", "", ...]
68
+ puts "\n#{@tty.capture}" # prints out the contents of the terminal
69
+ ```
51
70
 
52
71
  ### Example Canonical CLI/Shell
53
72
 
54
- 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.
73
+ Most people should use send_keys, if you are writing or working with a noncanonical shell/CLI, you will probably know it! Most shell/CLI applications are canonical.<br /><br />
74
+ There are more examples in the examples folder.
55
75
 
56
76
  ``` ruby
57
77
  require 'ttytest'
@@ -70,6 +90,8 @@ TTY
70
90
  @tty.assert_cursor_position(x: 2, y: 2)
71
91
 
72
92
  p @tty.rows # => ["$ echo \"Hello, world\"", "Hello, world", "$", "", "", "", ...]
93
+
94
+ puts "\n#{@tty.capture}" # prints out the contents of the terminal
73
95
  ```
74
96
 
75
97
  ### Example Noncanonical CLI/Shell
@@ -77,6 +99,7 @@ p @tty.rows # => ["$ echo \"Hello, world\"", "Hello, world", "$", "", "", "", ..
77
99
  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 />
78
100
  Also useful if you need to send input one character at a time for whatever reason.<br /><br />
79
101
  'Multi-character' characters like '\n' need to be sent with send-keys, though.<br /><br />
102
+ There are more examples in the examples folder.
80
103
 
81
104
  ``` ruby
82
105
  require 'ttytest'
@@ -96,6 +119,8 @@ require 'ttytest'
96
119
  @tty.assert_row_starts_with(0, ENV['USER'])
97
120
  @tty.assert_row_ends_with(0, '$')
98
121
  @tty.send_newline # an alternative to the 2 above methods to send \n to the terminal
122
+
123
+ puts "\n#{@tty.capture}" # prints out the contents of the terminal
99
124
  ```
100
125
 
101
126
  ### Constants
@@ -120,7 +120,8 @@ module TTYtest
120
120
 
121
121
  return if matched
122
122
 
123
- raise MatchError, "screen did not match expected content:\n--- expected\n+++ actual\n#{diff.join("\n")}"
123
+ raise MatchError,
124
+ "screen did not match expected content:\n--- expected\n+++ actual\n#{diff.join("\n")}"
124
125
  end
125
126
  alias assert_matches assert_contents
126
127
 
@@ -86,6 +86,50 @@ module TTYtest
86
86
  end
87
87
  end
88
88
 
89
+ def send_right_arrow
90
+ @tty.send_keys(TTYtest::RIGHT_ARROW)
91
+ end
92
+
93
+ def send_right_arrows(number_of_times)
94
+ while number_of_times.positive?
95
+ send_right_arrow
96
+ number_of_times -= 1
97
+ end
98
+ end
99
+
100
+ def send_left_arrow
101
+ @tty.send_keys(TTYtest::LEFT_ARROW)
102
+ end
103
+
104
+ def send_left_arrows(number_of_times)
105
+ while number_of_times.positive?
106
+ send_left_arrow
107
+ number_of_times -= 1
108
+ end
109
+ end
110
+
111
+ def send_up_arrow
112
+ @tty.send_keys(TTYtest::UP_ARROW)
113
+ end
114
+
115
+ def send_up_arrows(number_of_times)
116
+ while number_of_times.positive?
117
+ send_up_arrow
118
+ number_of_times -= 1
119
+ end
120
+ end
121
+
122
+ def send_down_arrow
123
+ @tty.send_keys(TTYtest::DOWN_ARROW)
124
+ end
125
+
126
+ def send_down_arrows(number_of_times)
127
+ while number_of_times.positive?
128
+ send_down_arrow
129
+ number_of_times -= 1
130
+ end
131
+ end
132
+
89
133
  # Useful to send send-keys commands to tmux without sending them as a string literal.
90
134
  # So you can send Escape for escape key, DC for delete, etc.
91
135
  # Uses the same key bindings as bind-key as well. C-c represents Ctrl + C keys, F1 is F1 key, etc.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TTYtest
4
- VERSION = '0.9.1'
4
+ VERSION = '0.9.2'
5
5
  end
data/notes.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  to push new version to github
2
- git tag v0.9.1
2
+ git tag v0.9.2
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.9.1.gem
7
+ gem push ttytest2-0.9.2.gem
data/ttytest2.gemspec CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ['Alex Eski']
11
11
  spec.email = ['alexeski@gmail.com']
12
12
 
13
- spec.summary = 'ttytest2 is an integration test framework for interactive tty applications. Based on TTYtest!'
14
- spec.description = 'ttytest2 allows running shell/cli applications inside of tmux and then making assertions on the output.'
13
+ spec.summary = 'ttytest2 is an integration test framework for interactive console (tty) applications'
14
+ spec.description = 'ttytest2 runs shell/cli applications inside of tmux and allows you to make assertions on what the output should be'
15
15
  spec.homepage = 'https://github.com/a-eski/ttytest2'
16
16
  spec.license = 'MIT'
17
17
 
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.required_ruby_version = '>= 3.2.3'
26
26
 
27
- spec.add_development_dependency 'bundler', '~> 2.5'
27
+ spec.add_development_dependency 'bundler', '~> 2.4'
28
28
  spec.add_development_dependency 'minitest', '~> 5.0'
29
29
  spec.add_development_dependency 'rake', '~> 13.0'
30
30
  spec.add_development_dependency 'yard', '~> 0.9'
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.9.1
4
+ version: 0.9.2
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-20 00:00:00.000000000 Z
11
+ date: 2024-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.5'
19
+ version: '2.4'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.5'
26
+ version: '2.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,8 +66,8 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.9'
69
- description: ttytest2 allows running shell/cli applications inside of tmux and then
70
- making assertions on the output.
69
+ description: ttytest2 runs shell/cli applications inside of tmux and allows you to
70
+ make assertions on what the output should be
71
71
  email:
72
72
  - alexeski@gmail.com
73
73
  executables: []
@@ -114,6 +114,5 @@ requirements: []
114
114
  rubygems_version: 3.4.20
115
115
  signing_key:
116
116
  specification_version: 4
117
- summary: ttytest2 is an integration test framework for interactive tty applications.
118
- Based on TTYtest!
117
+ summary: ttytest2 is an integration test framework for interactive console (tty) applications
119
118
  test_files: []