class MouseMelon::Tools::FeatureStepsParser

Public Instance Methods

parse(string) click to toggle source
# File lib/mouse_melon/tools/feature_steps_parser.rb, line 5
def parse(string)
  @steps = find_steps(string)
  strip_step_arguments
  strip_end_quotes
  drop_duplicate_steps
end

Protected Instance Methods

drop_duplicate_steps() click to toggle source
# File lib/mouse_melon/tools/feature_steps_parser.rb, line 18
def drop_duplicate_steps
  @steps.uniq!
end
find_steps(string) click to toggle source
# File lib/mouse_melon/tools/feature_steps_parser.rb, line 14
def find_steps(string)
  string.scan(/^\s*(?:Given|When|Then|And|But|Step)\s+['"](.+)['"]$/).flatten
end
strip_end_quotes() click to toggle source
# File lib/mouse_melon/tools/feature_steps_parser.rb, line 22
def strip_end_quotes
  @steps.map { |step| step.gsub(/\A["']+|["']+\z/, '') }
end
strip_step_arguments() click to toggle source
# File lib/mouse_melon/tools/feature_steps_parser.rb, line 26
def strip_step_arguments
  @steps = @steps.map do |step|
    step.split(/['"], /).first
  end
end