tui-td 0.2.3 → 0.2.4
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/CHANGELOG.md +8 -0
- data/README.md +4 -0
- data/lib/tui_td/cli.rb +14 -0
- data/lib/tui_td/matchers.rb +11 -0
- data/lib/tui_td/test_runner.rb +19 -0
- data/lib/tui_td/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 97ed62eebe255ca568235b0ffe8bb428812d0dbc0408e24e768d76e8b11beb8a
|
|
4
|
+
data.tar.gz: 8b66334f5408398dab8dcf02535e8473c2d9af7357f4fc1db45bc67ca792706c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 404c5b2c0c411b25846855d0d5ad297493be90672ee3eba53980df429ec1263170b605d023983a4fbc17c2b4563b10ff91c98324a08651cf0997d4a9cde21667
|
|
7
|
+
data.tar.gz: 5b73ca7cccaa81b434ca418e5f246573033ac5abd6c18b7094adad6f65d8fa453be2e8c84d842f2ba82e182a9189989a2389599874e1ab9448606db30677d901
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 0.2.4
|
|
4
|
+
|
|
5
|
+
- `assert_regex` JSON test step — match terminal output against a Ruby regex
|
|
6
|
+
- `assert_not_text` JSON test step — fail if text IS present (inverse of assert_text)
|
|
7
|
+
- `have_regex` RSpec matcher — regex assertions in spec files
|
|
8
|
+
- `have_text` negation in RSpec: `expect(state).not_to have_text("Error")`
|
|
9
|
+
- README step reference table updated (all 13 step types listed)
|
|
10
|
+
|
|
3
11
|
## 0.2.3
|
|
4
12
|
|
|
5
13
|
- `have_exit_status` RSpec matcher and `exitstatus` drive command — exit code testing on all three levels (JSON + RSpec + drive)
|
data/README.md
CHANGED
|
@@ -292,9 +292,13 @@ tui-td test examples/echo_test.json
|
|
|
292
292
|
| `wait_for_text` | `"text"` | Wait until text appears |
|
|
293
293
|
| `wait_for_stable` | — | Wait until output is stable |
|
|
294
294
|
| `assert_text` | `"text"` | Assert that text exists on screen |
|
|
295
|
+
| `assert_not_text` | `"text"` | Assert that text does NOT exist on screen |
|
|
296
|
+
| `assert_regex` | `"pattern"` | Assert that regex pattern matches (e.g. `"error\|fail"`) |
|
|
295
297
|
| `assert_fg` | `[row, col], "is": "color"` | Assert foreground color |
|
|
296
298
|
| `assert_bg` | `[row, col], "is": "color"` | Assert background color |
|
|
297
299
|
| `assert_style` | `[row, col], "bold": true` | Assert cell style (bold, italic, underline) |
|
|
300
|
+
| `wait_for_exit` | — | Wait until the process exits |
|
|
301
|
+
| `assert_exit` | `N` | Assert the process exit code equals N |
|
|
298
302
|
| `screenshot` | `"path"` | Save PNG screenshot |
|
|
299
303
|
| `html` | `"path"` | Save HTML render for browser viewing |
|
|
300
304
|
| `close` | — | Close the TUI |
|
data/lib/tui_td/cli.rb
CHANGED
|
@@ -366,6 +366,13 @@ module TUITD
|
|
|
366
366
|
{"assert_text": "<substring>"}
|
|
367
367
|
Fail if the text is not found in the current state.
|
|
368
368
|
|
|
369
|
+
{"assert_not_text": "<substring>"}
|
|
370
|
+
Fail if the text IS found in the current state.
|
|
371
|
+
|
|
372
|
+
{"assert_regex": "<pattern>"}
|
|
373
|
+
Fail if the regex pattern does not match anywhere.
|
|
374
|
+
Pattern syntax is Ruby regex (e.g. "error|fail|warn").
|
|
375
|
+
|
|
369
376
|
{"assert_fg": [row, col], "is": "<color>"}
|
|
370
377
|
Assert foreground color at cell. Colors: "default",
|
|
371
378
|
named ANSI (red, green, blue, cyan, ...), "bright_*",
|
|
@@ -432,6 +439,13 @@ module TUITD
|
|
|
432
439
|
have_text(expected)
|
|
433
440
|
Passes if expected text appears anywhere in the terminal state.
|
|
434
441
|
Usage: expect(state).to have_text("Hello")
|
|
442
|
+
Negate: expect(state).not_to have_text("Error")
|
|
443
|
+
|
|
444
|
+
have_regex(pattern)
|
|
445
|
+
Passes if the regex pattern matches anywhere. Accepts a Regexp
|
|
446
|
+
or a string (parsed as Ruby regex).
|
|
447
|
+
Usage: expect(state).to have_regex(/error|fail/)
|
|
448
|
+
Usage: expect(state).to have_regex("\\d{3}")
|
|
435
449
|
|
|
436
450
|
have_fg(expected).at(row, col)
|
|
437
451
|
Assert foreground color at [row, col] matches expected.
|
data/lib/tui_td/matchers.rb
CHANGED
|
@@ -23,6 +23,17 @@ module TUITD
|
|
|
23
23
|
failure_message_when_negated { |state| "expected terminal NOT to contain #{expected.inspect}" }
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
RSpec::Matchers.define :have_regex do |pattern|
|
|
27
|
+
match do |state|
|
|
28
|
+
@regex = pattern.is_a?(Regexp) ? pattern : Regexp.new(pattern.to_s)
|
|
29
|
+
state.find_text(@regex).any?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
description { "match regex #{pattern.inspect}" }
|
|
33
|
+
failure_message { |state| "expected terminal to match #{pattern.inspect}" }
|
|
34
|
+
failure_message_when_negated { |state| "expected terminal NOT to match #{pattern.inspect}" }
|
|
35
|
+
end
|
|
36
|
+
|
|
26
37
|
RSpec::Matchers.define :have_fg do |expected|
|
|
27
38
|
chain(:at) { |row, col| @row, @col = row, col }
|
|
28
39
|
|
data/lib/tui_td/test_runner.rb
CHANGED
|
@@ -101,6 +101,25 @@ module TUITD
|
|
|
101
101
|
Result.new(step: action, passed: false, message: "Text NOT found: #{value}")
|
|
102
102
|
end
|
|
103
103
|
|
|
104
|
+
when "assert_not_text"
|
|
105
|
+
ensure_driver!(driver)
|
|
106
|
+
state = State.new(driver.state_data)
|
|
107
|
+
if state.find_text(value.to_s).any?
|
|
108
|
+
Result.new(step: action, passed: false, message: "Text found but should not be: #{value}")
|
|
109
|
+
else
|
|
110
|
+
Result.new(step: action, passed: true, message: "Text not found: #{value}")
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
when "assert_regex"
|
|
114
|
+
ensure_driver!(driver)
|
|
115
|
+
state = State.new(driver.state_data)
|
|
116
|
+
pattern = Regexp.new(value.to_s)
|
|
117
|
+
if state.find_text(pattern).any?
|
|
118
|
+
Result.new(step: action, passed: true, message: "Regex matched: #{value}")
|
|
119
|
+
else
|
|
120
|
+
Result.new(step: action, passed: false, message: "Regex did not match: #{value}")
|
|
121
|
+
end
|
|
122
|
+
|
|
104
123
|
when "assert_fg"
|
|
105
124
|
ensure_driver!(driver)
|
|
106
125
|
row, col = coords(step)
|
data/lib/tui_td/version.rb
CHANGED