Sha256: db40131d6da8ef5833a21163ba360c105ae25faa65c8fff654864aab07f4ba64
Contents?: true
Size: 1.99 KB
Versions: 2
Compression:
Stored size: 1.99 KB
Contents
module Cucumber module TreetopParser grammar Feature rule root header scenarios { def feature f = Tree::Feature.new(header.text_value.strip) scenarios.populate(f) f end } end rule header (!step_scenario .)* end rule scenarios step_scenario more:(table / step_scenario)* { def populate(feature) step_scenario.populate(feature) more.elements.each { |m| m.populate(feature) } end } end rule step_scenario whitespace* scenario_keyword ":" whitespace* name:(!newline .)* newline* steps:step+ { def populate(feature) sc = feature.add_scenario(name.text_value) steps.elements.each{|s| s.populate(sc)} Feature.last_scenario = sc end } end rule step whitespace* step_keyword whitespace* name:(!newline .)* newline* { def populate(scenario) line = input.line_of(interval.first) scenario.add_step(step_keyword.text_value, name.text_value, line) end } end rule step_keyword '<%= words['given'] %>' / '<%= words['when'] %>' / '<%= words['then'] %>' / '<%= words['and'] %>' end rule scenario_keyword '<%= words['scenario'] %>' end rule table table_line more:(newline table_line)+ newline* { def populate(feature) Feature.last_scenario.table_header = table_line.values more.elements.each do |e| feature.add_row_scenario(Feature.last_scenario, e.table_line.values, e.table_line.line) end end } end rule table_line whitespace* separator cells:(whitespace* cell_value whitespace* separator)+ { def values cells.elements.map { |cell| cell.cell_value.text_value } end def line input.line_of(interval.first) end } end rule cell_value (!(separator / newline / whitespace) .)* end rule separator '|' end rule newline "\r\n?" / "\n" end rule whitespace [ \v\f\t] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aslakhellesoy-cucumber-0.1.1 | lib/cucumber/treetop_parser/feature.treetop.erb |
aslakhellesoy-cucumber-0.1.2 | lib/cucumber/treetop_parser/feature.treetop.erb |