Module: Cucumber::Runtime::UserInterface

Included in:
Cucumber::Runtime
Defined in:
lib/cucumber/runtime/user_interface.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) visitor=(visitor) (writeonly)

Sets the attribute visitor

Parameters:

  • value

    the value to set the attribute visitor to.



7
8
9
# File 'lib/cucumber/runtime/user_interface.rb', line 7

def visitor=(value)
  @visitor = value
end

Instance Method Details

- (Object) ask(question, timeout_seconds)

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.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cucumber/runtime/user_interface.rb', line 34

def ask(question, timeout_seconds)
  STDOUT.puts(question)
  STDOUT.flush
  puts(question)

  if(Cucumber::JRUBY)
    answer = jruby_gets(timeout_seconds)
  else
    answer = mri_gets(timeout_seconds)
  end

  if(answer)
    puts(answer)
    answer
  else
    raise("Waited for input for #{timeout_seconds} seconds, then timed out.")
  end
end

- (Object) embed(src, mime_type, label)

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.



57
58
59
# File 'lib/cucumber/runtime/user_interface.rb', line 57

def embed(src, mime_type, label)
  @visitor.embed(src, mime_type, label)
end

- (Object) puts(*messages)

Output messages alongside the formatted output. This is an alternative to using Kernel#puts - it will display nicer, and in all outputs (in case you use several formatters)



17
18
19
# File 'lib/cucumber/runtime/user_interface.rb', line 17

def puts(*messages)
  @visitor.puts(*messages)
end