class RatatuiRuby::Event::Sync
Synthetic event for synchronizing async operations in tests.
Testing async behavior is tricky. You inject an event, but results arrive later. By the time you assert, the async work may not have completed.
When a runtime (Tea, Kit) encounters this event, it should wait for all pending async operations to complete before processing the next event. This enables deterministic testing without changing production code paths.
Inject this event between user actions and assertions to ensure async results have been processed:
Example
inject_key("s") # Triggers async command
inject_sync # Wait for command to complete
inject_key(:q) # Quit after seeing results
Tea.run(...)
assert_snapshots("after_s_with_results")
This is not ātest modeāāitās a real event that runtimes handle. Production apps could use it too (e.g., āensure saves complete before quitā).
Public Instance Methods
Source
# File lib/ratatui_ruby/event/sync.rb, line 47 def deconstruct_keys(keys) { type: :sync } end
Deconstructs the event for pattern matching.