module Cucumber::Runtime::UserInterface
Attributes
Public Instance Methods
Source
# File lib/cucumber/runtime/user_interface.rb, line 24 def ask(question, timeout_seconds) $stdout.puts(question) $stdout.flush puts(question) answer = if Cucumber::JRUBY jruby_gets(timeout_seconds) else mri_gets(timeout_seconds) end raise("Waited for input for #{timeout_seconds} seconds, then timed out.") unless answer puts(answer) answer end
Suspends execution and prompts question to the console (STDOUT). An operator (manual tester) can then enter a line of text and hit <ENTER>. The entered text is returned, and both question and the result is added to the output using puts.
If you want a beep to happen (to grab the manual tester’s attention), just prepend ASCII character 7 to the question:
ask("#{7.chr}How many cukes are in the external system?")
If that doesn’t issue a beep, you can shell out to something else that makes a sound before invoking ask.
Source
# File lib/cucumber/runtime/user_interface.rb, line 45 def attach(src, media_type, filename) @configuration.notify(:attach_called, src, media_type, filename) self end
Embed src of MIME type mime_type into the output. The src argument may be a path to a file, or if it’s an image it may also be a Base64 encoded image. The embedded data may or may not be ignored, depending on what kind of formatter(s) are active.
Private Instance Methods
Source
# File lib/cucumber/runtime/user_interface.rb, line 60 def jruby_gets(timeout_seconds) answer = nil t = java.lang.Thread.new do answer = $stdin.gets end t.start t.join(timeout_seconds * 1000) answer end
Source
# File lib/cucumber/runtime/user_interface.rb, line 52 def mri_gets(timeout_seconds) Timeout.timeout(timeout_seconds) do $stdin.gets end rescue Timeout::Error nil end