Parent

Included Modules

Files

Class/Module Index [+]

Quicksearch

Cucumber::Parser::GherkinBuilder

This class conforms to the Gherkin event API and builds the "legacy" AST. It will be replaced later when we have a new "clean" AST.

Public Instance Methods

ast() click to toggle source
# File lib/cucumber/parser/gherkin_builder.rb, line 13
def ast
  @feature || @multiline_arg
end
background(background) click to toggle source
# File lib/cucumber/parser/gherkin_builder.rb, line 31
def background(background)
  @background = Ast::Background.new(
    Ast::Comment.new(background.comments.map{|comment| comment.value}.join("\n")), 
    background.line, 
    background.keyword, 
    background.name, 
    background.description,
    steps=[]
  )
  @feature.background = @background
  @background.feature = @feature
  @step_container = @background
  @background.gherkin_statement(background)
end
eof() click to toggle source
# File lib/cucumber/parser/gherkin_builder.rb, line 107
def eof
end
examples(examples) click to toggle source
# File lib/cucumber/parser/gherkin_builder.rb, line 84
def examples(examples)
  examples_fields = [
    Ast::Comment.new(examples.comments.map{|comment| comment.value}.join("\n")), 
    examples.line, 
    examples.keyword, 
    examples.name, 
    examples.description, 
    matrix(examples.rows)
  ]
  @step_container.add_examples(examples_fields, examples)
end
feature(feature) click to toggle source
# File lib/cucumber/parser/gherkin_builder.rb, line 17
def feature(feature)
  @feature = Ast::Feature.new(
    nil, 
    Ast::Comment.new(feature.comments.map{|comment| comment.value}.join("\n")), 
    Ast::Tags.new(nil, feature.tags),
    feature.keyword,
    feature.name.lstrip,
    feature.description.rstrip,
    []
  )
  @feature.gherkin_statement(feature)
  @feature
end
scenario(statement) click to toggle source
# File lib/cucumber/parser/gherkin_builder.rb, line 46
def scenario(statement)
  scenario = Ast::Scenario.new(
    @background, 
    Ast::Comment.new(statement.comments.map{|comment| comment.value}.join("\n")), 
    Ast::Tags.new(nil, statement.tags), 
    statement.line, 
    statement.keyword, 
    statement.name,
    statement.description, 
    steps=[]
  )
  @feature.add_feature_element(scenario)
  @background.feature_elements << scenario if @background
  @step_container = scenario
  scenario.gherkin_statement(statement)
end
scenario_outline(statement) click to toggle source
# File lib/cucumber/parser/gherkin_builder.rb, line 63
def scenario_outline(statement)
  scenario_outline = Ast::ScenarioOutline.new(
    @background, 
    Ast::Comment.new(statement.comments.map{|comment| comment.value}.join("\n")), 
    Ast::Tags.new(nil, statement.tags), 
    statement.line, 
    statement.keyword, 
    statement.name, 
    statement.description, 
    steps=[],
    example_sections=[]
  )
  @feature.add_feature_element(scenario_outline)
  if @background
    @background = @background.dup
    @background.feature_elements << scenario_outline
  end
  @step_container = scenario_outline
  scenario_outline.gherkin_statement(statement)
end
step(gherkin_step) click to toggle source
# File lib/cucumber/parser/gherkin_builder.rb, line 96
def step(gherkin_step)
  step = Ast::Step.new(
    gherkin_step.line, 
    gherkin_step.keyword, 
    gherkin_step.name, 
    Ast::MultilineArgument.from(gherkin_step.doc_string || gherkin_step.rows)
  )
  step.gherkin_statement(gherkin_step)
  @step_container.add_step(step)
end
syntax_error(state, event, legal_events, line) click to toggle source
# File lib/cucumber/parser/gherkin_builder.rb, line 110
def syntax_error(state, event, legal_events, line)
  # raise "SYNTAX ERROR"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.