class Cucumberator::Input
Attributes
exit_flag[RW]
last_input[RW]
saved_stack[RW]
scenario[RW]
step_line[RW]
world[RW]
Public Class Methods
new(world, scenario, step_line = nil)
click to toggle source
# 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
Public Instance Methods
check_scenario()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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