Class: Turnip::Node::Feature

Inherits:
Base
  • Object
show all
Includes:
HasTags
Defined in:
lib/turnip/node/feature.rb

Overview

Note:

Feature metadata generated by Gherkin

{

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

}

Instance Attribute Summary

Attributes inherited from Base

#raw

Instance Method Summary collapse

Methods included from HasTags

#tag_names, #tags

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

#backgroundsObject



55
56
57
58
59
# File 'lib/turnip/node/feature.rb', line 55

def backgrounds
  @backgrounds ||= children.select do |c|
    c.is_a?(Background)
  end
end

#childrenObject



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/turnip/node/feature.rb', line 42

def children
  @children ||= @raw[:children].map do |c|
    case c[:type]
    when :Background
      Background.new(c)
    when :Scenario
      Scenario.new(c)
    when :ScenarioOutline
      ScenarioOutline.new(c)
    end
  end.compact
end

#descriptionObject



38
39
40
# File 'lib/turnip/node/feature.rb', line 38

def description
  @raw[:description]
end

#keywordObject



34
35
36
# File 'lib/turnip/node/feature.rb', line 34

def keyword
  @raw[:keyword]
end

#languageObject



30
31
32
# File 'lib/turnip/node/feature.rb', line 30

def language
  @raw[:language]
end

#metadata_hashObject



72
73
74
# File 'lib/turnip/node/feature.rb', line 72

def 
  super.merge(:type => Turnip.type, :turnip => true)
end

#nameObject



26
27
28
# File 'lib/turnip/node/feature.rb', line 26

def name
  @raw[:name]
end

#scenariosObject



61
62
63
64
65
66
67
68
69
70
# File 'lib/turnip/node/feature.rb', line 61

def scenarios
  @scenarios ||= children.map do |c|
    case c
    when Scenario
      c
    when ScenarioOutline
      c.to_scenarios
    end
  end.flatten.compact
end