Class: Clack::Testing::KeyQueue
- Inherits:
-
Object
- Object
- Clack::Testing::KeyQueue
- Defined in:
- lib/clack/testing.rb
Overview
A StringIO-like object that feeds keys from a queue. Passed as the input: parameter to prompts for testing.
Instance Method Summary collapse
- #getc ⇒ Object
-
#initialize(keys) ⇒ KeyQueue
constructor
A new instance of KeyQueue.
-
#tty? ⇒ Boolean
Not a real TTY.
Constructor Details
#initialize(keys) ⇒ KeyQueue
Returns a new instance of KeyQueue.
111 112 113 114 |
# File 'lib/clack/testing.rb', line 111 def initialize(keys) @keys = keys @read_count = 0 end |
Instance Method Details
#getc ⇒ Object
116 117 118 119 120 121 |
# File 'lib/clack/testing.rb', line 116 def getc @read_count += 1 raise "Too many reads (#{@read_count}) - possible infinite loop in test" if @read_count > 100 @keys.shift || KEYS[:enter] end |
#tty? ⇒ Boolean
Not a real TTY
124 |
# File 'lib/clack/testing.rb', line 124 def tty? = false |