Class: Specific::Processor::Gherkin

Inherits:
Object
  • Object
show all
Defined in:
lib/specific/processor/gherkin.rb

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ Gherkin

Returns a new instance of Gherkin.



6
7
8
# File 'lib/specific/processor/gherkin.rb', line 6

def initialize(spec)
  @spec = spec
end

Instance Method Details

#execute(ast) ⇒ Object



10
11
12
# File 'lib/specific/processor/gherkin.rb', line 10

def execute(ast)
  ast.accept(self)
end

#visit_Feature(ast_feature) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/specific/processor/gherkin.rb', line 14

def visit_Feature(ast_feature)
  tags = ast_feature.tags.map do |ast_tag|
    Specific::Tag.new(ast_tag.name)
  end

  scenarios = ast_feature.scenarios.map do |ast_scenario|
    steps = ast_scenario.steps.map do |ast_step|
      Specific::Step.new(ast_step.keyword, ast_step.name)
    end
    Specific::Scenario.new(ast_scenario.name, steps)
  end

  feature = Specific::Feature.new(
    ast_feature.name, 
    tags, 
    ast_feature.description,
    scenarios
  )
  @spec.add_feature feature
end