ttytest2 1.0.7 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ec86d17bfe3b3a9c9485f0b53c14f4dcfebd5e875dd2ba1de7f26c7ef4b1a87
4
- data.tar.gz: 2b53db154e9c680b89897bc46cffe087d415ce22049727ec1b3ff698ce80aba0
3
+ metadata.gz: 47258d8644be543f645de9e34a17eca3a0e38c5fb764e4e72f4d78a63a888388
4
+ data.tar.gz: 4aa9221ee6fc4f5e8fda754b2cd3b9c8218d7b8cf1e7e8b67dfe2a36dd9360b8
5
5
  SHA512:
6
- metadata.gz: 5db41e82f2c81e5df9e8305f51431b58fafac9abe95b23eaf64f7e7f8e13c64ca5b1be21784b67438938579dd503cbd430128c6984e94b8fa69990c9d9e7b0cf
7
- data.tar.gz: 22e3f4c4609432321cf5c7abe0f061e15f52816f89f1d8dd87283aef6d9d78dd661fe991edc074dbfd354024aaa59278799d332b29d3cd32460ef0d2bf665d4d
6
+ metadata.gz: f20f297c6b30fb549ade96a5a2644f11e9ad846f0e8950f5e119bcfc83a63228dcbe51b75e635fdcfeb0bd47b17122bf568e574305406582cf4a0e9978356137
7
+ data.tar.gz: 0ee8c938c0b66151ba208c1769bfd5ac65277d1c62dbc3ede3976926dfef964870a7119b6003601c4f2fb0c7a90cc2d6736e8cffc9df86de81d7f6efc5c2877a
data/README.md CHANGED
@@ -121,6 +121,8 @@ If you are reading this on github, the ruby docs accessible from [RubyDoc.Info](
121
121
 
122
122
  * `assert_row_regexp(row_number, regexp_str)`
123
123
 
124
+ * `assert_rows_each_match_regexp(row_start, row_end, regexp_str)`
125
+
124
126
  * `assert_cursor_position(x: x, y: y)`
125
127
 
126
128
  * `assert_cursor_visible`
@@ -131,6 +133,22 @@ If you are reading this on github, the ruby docs accessible from [RubyDoc.Info](
131
133
 
132
134
  * `assert_contents_at(row_start, row_end, expected_text)`
133
135
 
136
+ * `assert_contents_include(expected)`
137
+
138
+ * `assert_contents_empty`
139
+
140
+ * `assert_contents_match_regexp(regexp_str)`
141
+
142
+ * `assert_file_exists(file_path)`
143
+
144
+ * `assert_file_doesnt_exist(file_path)`
145
+
146
+ * `assert_file_contains(file_path, needle)`
147
+
148
+ * `assert_file_has_permissions(file_path, permissions)`
149
+
150
+ * `assert_file_has_line_count(file_path, expected_count)`
151
+
134
152
  ## Output
135
153
 
136
154
  You can send output to the terminal with the following calls.
@@ -139,7 +139,7 @@ module TTYtest
139
139
  "expected row #{index} to match regexp #{regexp_str} but it did not. Row value #{get_inspection(actual_row)}\nEntire screen:\n#{self}"
140
140
  end
141
141
  end
142
- alias assert_line_each_match_regexp assert_rows_each_match_regexp
142
+ alias assert_lines_each_match_regexp assert_rows_each_match_regexp
143
143
 
144
144
  # Asserts that the cursor is in the expected position
145
145
  # @param [Integer] x cursor x (row) position, starting from 0
@@ -155,6 +155,7 @@ module TTYtest
155
155
  "expected cursor to be at #{expected.inspect} but was at #{get_inspection(actual)}\nEntire screen:\n#{self}"
156
156
  end
157
157
 
158
+ # Asserts the cursor is currently visible
158
159
  # @raise [MatchError] if the cursor is hidden
159
160
  def assert_cursor_visible
160
161
  return if cursor_visible?
@@ -162,6 +163,7 @@ module TTYtest
162
163
  raise MatchError, "expected cursor to be visible was hidden\nEntire screen:\n#{self}"
163
164
  end
164
165
 
166
+ # Asserts the cursor is currently hidden
165
167
  # @raise [MatchError] if the cursor is visible
166
168
  def assert_cursor_hidden
167
169
  return if cursor_hidden?
@@ -200,11 +202,56 @@ module TTYtest
200
202
  alias assert_matches_at assert_contents_at
201
203
  alias assert_rows assert_contents_at
202
204
 
205
+ # Asserts the contents of the screen include the passed in string
206
+ # @param [String] expected the string value expected to be found in the screen contents
207
+ # @raise [MatchError] if the screen does not contain the expected value
208
+ def assert_contents_include(expected)
209
+ found = false
210
+ rows.each do |row|
211
+ found = true if row.include?(expected)
212
+ end
213
+ return if found
214
+
215
+ raise MatchError,
216
+ "Expected screen contents to include #{expected}, but it was not found.\nEntire screen:\n#{self}"
217
+ end
218
+ alias assert_screen_includes assert_contents_include
219
+
220
+ # Asserts the contents of the screen are empty
221
+ # @raise [MatchError] if the screen is not empty
222
+ def assert_contents_empty
223
+ return if rows.all? { |s| s.to_s.empty? }
224
+
225
+ raise MatchError,
226
+ "Expected screen to be empty, but found content.\nEntire screen:\n#{self}"
227
+ end
228
+ alias assert_screen_empty assert_contents_empty
229
+
230
+ # Asserts the contents of the screen as a single string match the passed in regular expression
231
+ # @param [String] regexp_str the regular expression as a string that will be used to match with
232
+ # @raise [MatchError] if the screen as a string doesn't match against the regular expression
233
+ def assert_contents_match_regexp(regexp_str)
234
+ regexp = Regexp.new(regexp_str)
235
+ screen = capture.to_s
236
+
237
+ return if !screen.nil? && screen.match?(regexp)
238
+
239
+ raise MatchError,
240
+ "Expected screen contents to match regexp #{regexp_str} but they did not\nEntire screen:\n#{self}"
241
+ end
242
+ alias assert_screen_matches_regexp assert_contents_match_regexp
243
+
244
+ # Asserts the specified file exists
245
+ # @param [String] file_path the path to the file
246
+ # @raise [MatchError] if the file is not found or is a directory/symlink
203
247
  def assert_file_exists(file_path)
204
248
  raise file_not_found_error(file_path) unless File.exist?(file_path)
205
249
  raise file_is_dir_error(file_path) unless File.file?(file_path)
206
250
  end
207
251
 
252
+ # Asserts the specified file does not exists
253
+ # @param [String] file_path the path to the file
254
+ # @raise [MatchError] if the file is found or is a directory/symlink
208
255
  def assert_file_doesnt_exist(file_path)
209
256
  return unless File.exist?(file_path) || File.file?(file_path)
210
257
 
@@ -212,6 +259,10 @@ module TTYtest
212
259
  "File with path #{file_path} was found or is a directory when it was asserted it did not exist.\nEntire screen:\n#{self}"
213
260
  end
214
261
 
262
+ # Asserts the specified file contains the passed in string value
263
+ # @param [String] file_path the path to the file
264
+ # @param [String] needle the value to search for in the file
265
+ # @raise [MatchError] if the file does not contain value in variable needle
215
266
  def assert_file_contains(file_path, needle)
216
267
  raise file_not_found_error(file_path) unless File.exist?(file_path)
217
268
  raise file_is_dir_error(file_path) unless File.file?(file_path)
@@ -230,6 +281,10 @@ module TTYtest
230
281
  end
231
282
  alias assert_file_like assert_file_contains
232
283
 
284
+ # Asserts the specified file has the permissions specified
285
+ # @param [String] file_path the path to the file
286
+ # @param [String] permissions the expected permissions of the file (in form '644' or '775')
287
+ # @raise [MatchError] if the file has different permissions than specified
233
288
  def assert_file_has_permissions(file_path, permissions)
234
289
  raise file_not_found_error(file_path) unless File.exist?(file_path)
235
290
  raise file_is_dir_error(file_path) unless File.file?(file_path)
@@ -242,6 +297,10 @@ module TTYtest
242
297
  "File had permissions #{perms_octal}, not #{permissions} as expected.\n Entire screen:\n#{self}"
243
298
  end
244
299
 
300
+ # Asserts the specified file has line count specified
301
+ # @param [String] file_path the path to the file
302
+ # @param [String] expected_count the expected line count of the file
303
+ # @raise [MatchError] if the file has a different line count than specified
245
304
  def assert_file_has_line_count(file_path, expected_count)
246
305
  raise file_not_found_error(file_path) unless File.exist?(file_path)
247
306
  raise file_is_dir_error(file_path) unless File.file?(file_path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TTYtest
4
- VERSION = '1.0.7'
4
+ VERSION = '1.1.0'
5
5
  end
data/notes.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  to push new version to github
2
- git tag v1.0.7
2
+ git tag v1.1.0
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-1.0.7.gem
7
+ gem push ttytest2-1.1.0.gem
data/todo.txt CHANGED
@@ -1,2 +1,6 @@
1
1
  assert_exit_code(0) # For success
2
2
  assert_exit_code(1) # For expected failure
3
+ assert_variable_equals
4
+ assert_prompt
5
+ assert_prompt_after("command failed")
6
+ assert_style(row, col, style)
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 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'
13
+ spec.summary = 'ttytest2 is for integration/acceptance testing your shells/CLIs/REPLs.'
14
+ spec.description = 'ttytest2 is an integration test framework for interactive console (tty) applications'
15
15
  spec.homepage = 'https://github.com/a-eski/ttytest2'
16
16
  spec.license = 'MIT'
17
17
 
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: 1.0.7
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Eski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-08-01 00:00:00.000000000 Z
11
+ date: 2025-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,8 +80,8 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.9'
83
- description: ttytest2 runs shell/cli applications inside of tmux and allows you to
84
- make assertions on what the output should be
83
+ description: ttytest2 is an integration test framework for interactive console (tty)
84
+ applications
85
85
  email:
86
86
  - alexeski@gmail.com
87
87
  executables: []
@@ -129,5 +129,5 @@ requirements: []
129
129
  rubygems_version: 3.4.20
130
130
  signing_key:
131
131
  specification_version: 4
132
- summary: ttytest2 is an integration test framework for interactive console (tty) applications
132
+ summary: ttytest2 is for integration/acceptance testing your shells/CLIs/REPLs.
133
133
  test_files: []