Class: Turnip::Node::Rule

Inherits:
ScenarioGroupDefinition show all
Defined in:
lib/turnip/node/rule.rb

Overview

Note:

Rule metadata generated by Gherkin

{

type: :Rule,
location: { line: 10, column: 3 },
keyword: 'Rule',
name: 'Rule name',
description: 'Rule description',
children: [] # Array of Background, Scenario and Scenario Outline

}

Instance Attribute Summary

Attributes inherited from Base

#raw

Instance Method Summary collapse

Methods inherited from ScenarioGroupDefinition

#backgrounds, #description, #keyword, #name, #scenarios

Methods inherited from Base

#initialize

Methods included from HasLocation

#line, #location

Constructor Details

This class inherits a constructor from Turnip::Node::Base

Instance Method Details

#childrenObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/turnip/node/rule.rb', line 18

def children
  @children ||= @raw[:children].map do |child|
    unless child[:background].nil?
      next Background.new(child[:background])
    end

    unless child[:scenario].nil?
      klass = child.dig(:scenario, :examples).nil? ? Scenario : ScenarioOutline
      next klass.new(child[:scenario])
    end
  end.compact
end