Class: TTY::TestPrompt

Inherits:
Prompt
  • Object
show all
Defined in:
lib/tty/test_prompt.rb

Overview

Used for initializing test cases

Constant Summary

Constants inherited from Prompt

Prompt::ArgumentRequired, Prompt::ArgumentValidation, Prompt::ConfigurationError, Prompt::ConversionError, Prompt::InvalidArgument, Prompt::VERSION, Prompt::ValidationCoercion

Instance Attribute Summary

Attributes inherited from Prompt

#active_color, #cursor, #enabled_color, #error_color, #help_color, #input, #output, #prefix, #reader

Instance Method Summary collapse

Methods inherited from Prompt

#ask, #collect, #enum_select, #error, #expand, #inspect, #invoke_question, #invoke_select, #keypress, #mask, messages, #multi_select, #multiline, #no?, #ok, #say, #select, #slider, #stderr, #stdin, #stdout, #suggest, #tty?, #warn, #yes?

Constructor Details

#initialize(options = {}) ⇒ TestPrompt

Returns a new instance of TestPrompt.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tty/test_prompt.rb', line 8

def initialize(options = {})
  @input  = StringIO.new
  @output = StringIO.new
  options.merge!({
    input: @input,
    output: @output,
    env: { "TTY_TEST" => true },
    enable_color: options.fetch(:enable_color) { true }
  })
  super(options)
end