class Stepdown::StepInstance

Public Class Methods

const_missing(*args) click to toggle source
# File lib/stepdown/step_instance.rb, line 25
def self.const_missing(*args)
  self
end
method_missing(*args) click to toggle source
# File lib/stepdown/step_instance.rb, line 17
def self.method_missing(*args)
  #nothing
end
new() click to toggle source
# File lib/stepdown/step_instance.rb, line 6
def initialize
  @steps = []
  Gherkin::I18n.code_keywords.each do |code|
    self.class.send(:alias_method, code, :define_step)
  end
end

Public Instance Methods

define_step(regex,&block) click to toggle source
# File lib/stepdown/step_instance.rb, line 13
def define_step(regex,&block)
  @steps << regex
end
line_matches(line) click to toggle source
# File lib/stepdown/step_instance.rb, line 33
def line_matches(line)
  #stripped_line = line.strip.gsub(/^(And|Given|When|Then) (.*)$/,'\2')

  @steps.each_with_index do |regex,i|
    match = regex.match(line)
    if match
      return step_collection.detect{|step| i == step.id}
    end
  end

  return nil
end
method_missing(*args) click to toggle source
# File lib/stepdown/step_instance.rb, line 21
def method_missing(*args)
  #nothing
end
require(*args) click to toggle source
# File lib/stepdown/step_instance.rb, line 29
def require(*args)
  # do nothing
end
step_collection() click to toggle source
# File lib/stepdown/step_instance.rb, line 46
def step_collection
  return @step_collection if @step_collection
  @step_collection = StepCollection.new
  @steps.each_with_index do |regex, i|
    @step_collection.add_step(i, regex)
  end
  @step_collection
end