Class: Cucumberator::Input
- Inherits:
-
Object
- Object
- Cucumberator::Input
- Defined in:
- lib/cucumberator/input.rb
Instance Attribute Summary collapse
-
#exit_flag ⇒ Object
Returns the value of attribute exit_flag.
-
#last_input ⇒ Object
Returns the value of attribute last_input.
-
#saved_stack ⇒ Object
Returns the value of attribute saved_stack.
-
#scenario ⇒ Object
Returns the value of attribute scenario.
-
#step_line ⇒ Object
Returns the value of attribute step_line.
-
#world ⇒ Object
Returns the value of attribute world.
Instance Method Summary collapse
- #check_scenario ⇒ Object
-
#initialize(world, scenario, step_line = nil) ⇒ Input
constructor
A new instance of Input.
- #read_input ⇒ Object
- #set_autocomplete ⇒ Object
Constructor Details
#initialize(world, scenario, step_line = nil) ⇒ Input
Returns a new instance of Input.
8 9 10 11 12 13 14 15 16 |
# File 'lib/cucumberator/input.rb', line 8 def initialize(world, scenario, step_line = nil) @world, @scenario = world, scenario @step_line = step_line if step_line @saved_stack = [] check_scenario set_autocomplete read_input end |
Instance Attribute Details
#exit_flag ⇒ Object
Returns the value of attribute exit_flag.
6 7 8 |
# File 'lib/cucumberator/input.rb', line 6 def exit_flag @exit_flag end |
#last_input ⇒ Object
Returns the value of attribute last_input.
6 7 8 |
# File 'lib/cucumberator/input.rb', line 6 def last_input @last_input end |
#saved_stack ⇒ Object
Returns the value of attribute saved_stack.
6 7 8 |
# File 'lib/cucumberator/input.rb', line 6 def saved_stack @saved_stack end |
#scenario ⇒ Object
Returns the value of attribute scenario.
6 7 8 |
# File 'lib/cucumberator/input.rb', line 6 def scenario @scenario end |
#step_line ⇒ Object
Returns the value of attribute step_line.
6 7 8 |
# File 'lib/cucumberator/input.rb', line 6 def step_line @step_line end |
#world ⇒ Object
Returns the value of attribute world.
6 7 8 |
# File 'lib/cucumberator/input.rb', line 6 def world @world end |
Instance Method Details
#check_scenario ⇒ Object
18 19 20 |
# File 'lib/cucumberator/input.rb', line 18 def check_scenario raise "Sorry, cucumberator is not available when scenario is already failing!" if scenario.failed? end |
#read_input ⇒ Object
22 23 24 25 26 |
# File 'lib/cucumberator/input.rb', line 22 def read_input input = Readline.readline("> ", true) exit_flag = Cucumberator::Parser.parse_input(input, scenario, step_line, world, saved_stack) read_input unless exit_flag end |
#set_autocomplete ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cucumberator/input.rb', line 28 def set_autocomplete commands = Cucumberator::Commands::AVAILABLE Cucumberator::Steps.new(scenario).all.each do |s| # remove typical start/end regexp parts step = s.gsub(/^\/\^|\$\/$/,'') # every step is equal, no matter if When/Then/And, so combining everything for autocomplete commands << "When #{step}" << "Then #{step}" << "And #{step}" end Readline.basic_word_break_characters = ""; # no break chars = no autobreaking for completion input Readline.completion_proc = proc { |s| commands.grep( /^#{Regexp.escape(s)}/ ) } end |