Termisu::Testing::Terminal
Inherits Reference / Object
High-level E2E harness: spawns a program on a PTY, continuously emulates its
output into a Screen, and exposes assertion helpers that mirror JS terminal
test runners (get_by_text, get_cursor, snapshot) — with auto-retrying
waits so tests don't sprinkle fixed sleeps.
Prefer the block form which guarantees cleanup:
Termisu::Testing.terminal("./bin/app", cols: 100, rows: 50) do |t|
t.get_by_text("Ready").should be_true
t.write("q")
end
Constants
Byte sequences for common special keys (xterm/standard).
Constructors
Class methods
Spawns program, yields the harness, and always cleans up.
Instance methods
Current {x, y} of pattern right now, without waiting (returns nil if
absent). Use for polling a moving element; use locate to wait for it to
appear. Reads @screen under the same lock the reader fiber writes with.
Waits (up to timeout) until pattern appears on screen. Returns whether
it became visible — assert with .should be_true.
Waits for pattern to appear, then returns its first {x, y} (or nil).
Resizes the terminal (delivers SIGWINCH to the child).
Styled snapshot of the rendered screen (glyph grid + per-cell fg/bg/attr). mask blanks volatile regions (matched per row) so animated screens are deterministic.
Blocks until the program has produced no new output for quiet_for
(render-stable), or timeout elapses. Returns whether the screen actually
stabilized: animated screens (a spinner, a moving element) never quiesce
and return false on timeout by design — callers mask the volatile region
rather than rely on stability.
Blocks until block returns true, or timeout elapses. Yields to the reader fiber between checks (no busy spin).