ttytest2 1.5.0 → 1.6.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 +4 -4
- data/README.md +4 -0
- data/lib/ttytest/assertions/column_assertions.rb +26 -0
- data/lib/ttytest/assertions/row_assertions.rb +27 -1
- data/lib/ttytest/version.rb +1 -1
- data/notes.txt +2 -2
- 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: efba349f76f4726f156f95a655ead1afadfbcb9cce9ce06f15f87d9861186535
|
4
|
+
data.tar.gz: '0853b6b8a00b864d1b53b0d8517b25ecb3337051d0e4e73cac7f9aa0d676b2cd'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa99a3bab7f20c1c9568dde993bc466506087b19e136f8cb45b6617482cb5fc3c9af8344fddf21d591e5026c9a5b16ca4dd57f97c2717d2311a6993c8511ed54
|
7
|
+
data.tar.gz: 9d754810ae1f74c45db37ae4ac1de7495dbc5b83e786c29fd8c5f9be9f91e57e895638555bee13920ce6705b27a35ae33e5b22c3e6e5f99f4b7f5041325ba21f
|
data/README.md
CHANGED
@@ -134,6 +134,8 @@ If you are reading this on github, the ruby docs accessible from [RubyDoc.Info](
|
|
134
134
|
|
135
135
|
* `assert_rows_each_match_regexp(row_start, row_end, regexp_str)`
|
136
136
|
|
137
|
+
* `assert_rows_match_regexp(row_start, row_end, regexp_str, remove_newlines: false)`
|
138
|
+
|
137
139
|
#### Column Assertions
|
138
140
|
|
139
141
|
* `assert_column(col_number, expected_text)`
|
@@ -150,6 +152,8 @@ If you are reading this on github, the ruby docs accessible from [RubyDoc.Info](
|
|
150
152
|
|
151
153
|
* `assert_columns_each_match_regexp(col_start, col_end, regexp_str)`
|
152
154
|
|
155
|
+
* `assert_columns_match_regexp(col_start, col_end, regexp_str, remove_newlines: false)`
|
156
|
+
|
153
157
|
#### Cursor Assertions
|
154
158
|
|
155
159
|
* `assert_cursor_position(x: x, y: y)`
|
@@ -151,6 +151,32 @@ module TTYtest
|
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
154
|
+
# Asserts the contents of multiple columns match the passed in regular expression.
|
155
|
+
# @param [Integer] col_start the column (starting from 0) to test against
|
156
|
+
# @param [Integer] col_end the last column to test against
|
157
|
+
# @param [String] regexp_str the regular expression as a string that will be used to match with.
|
158
|
+
# @param [bool] remove_newlines an optional paramter to specify if line separators should be removed, defaults to false
|
159
|
+
# @raise [MatchError] if the columns don't match against the regular expression
|
160
|
+
def assert_columns_match_regexp(col_start, col_end, regexp_str, remove_newlines: false)
|
161
|
+
validate(col_end)
|
162
|
+
regexp = Regexp.new(regexp_str)
|
163
|
+
col_cur = col_start
|
164
|
+
col_end += 1 if col_end.zero?
|
165
|
+
actual = ''
|
166
|
+
|
167
|
+
while col_cur < col_end
|
168
|
+
col = get_column(col_cur).join
|
169
|
+
col = col.rstrip if remove_newlines
|
170
|
+
actual += col
|
171
|
+
col_cur += 1
|
172
|
+
end
|
173
|
+
|
174
|
+
return if !actual.nil? && actual.match?(regexp)
|
175
|
+
|
176
|
+
raise MatchError,
|
177
|
+
"expected columns #{col_start}-#{col_end} to match regexp #{regexp_str} but they did not. Columns value #{get_inspection(actual)}\nEntire screen:\n#{self}"
|
178
|
+
end
|
179
|
+
|
154
180
|
private
|
155
181
|
|
156
182
|
def get_column(col_number)
|
@@ -125,7 +125,7 @@ module TTYtest
|
|
125
125
|
# @param [Integer] row_start the row (starting from 0) to test against
|
126
126
|
# @param [Integer] row_end the last row to test against
|
127
127
|
# @param [String] regexp_str the regular expression as a string that will be used to match with.
|
128
|
-
# @raise [MatchError] if
|
128
|
+
# @raise [MatchError] if a row doesn't match against the regular expression
|
129
129
|
def assert_rows_each_match_regexp(row_start, row_end, regexp_str)
|
130
130
|
validate(row_end)
|
131
131
|
regexp = Regexp.new(regexp_str)
|
@@ -139,5 +139,31 @@ module TTYtest
|
|
139
139
|
end
|
140
140
|
end
|
141
141
|
alias assert_lines_each_match_regexp assert_rows_each_match_regexp
|
142
|
+
|
143
|
+
# Asserts the contents of multiple rows match the passed in regular expression.
|
144
|
+
# @param [Integer] row_start the row (starting from 0) to test against
|
145
|
+
# @param [Integer] row_end the last row to test against
|
146
|
+
# @param [String] regexp_str the regular expression as a string that will be used to match with.
|
147
|
+
# @param [bool] remove_newlines an optional paramter to specify if line separators should be removed, defaults to false
|
148
|
+
# @raise [MatchError] if the rows don't match against the regular expression
|
149
|
+
def assert_rows_match_regexp(row_start, row_end, regexp_str, remove_newlines: false)
|
150
|
+
validate(row_end)
|
151
|
+
regexp = Regexp.new(regexp_str)
|
152
|
+
row_end += 1 if row_end.zero?
|
153
|
+
|
154
|
+
slices = rows.slice(row_start, row_end)
|
155
|
+
if remove_newlines
|
156
|
+
slices.each_with_index do |slice, i|
|
157
|
+
slices[i] = slice.rstrip
|
158
|
+
end
|
159
|
+
end
|
160
|
+
actual = slices.join
|
161
|
+
|
162
|
+
return if !actual.nil? && actual.match?(regexp)
|
163
|
+
|
164
|
+
raise MatchError,
|
165
|
+
"expected rows #{row_start}-#{row_end} to match regexp #{regexp_str} but they did not. Rows value #{get_inspection(actual)}\nEntire screen:\n#{self}"
|
166
|
+
end
|
167
|
+
alias assert_lines_match_regexp assert_rows_match_regexp
|
142
168
|
end
|
143
169
|
end
|
data/lib/ttytest/version.rb
CHANGED
data/notes.txt
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: 1.
|
4
|
+
version: 1.6.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-10-
|
11
|
+
date: 2025-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|