Class: Turnip::Node::ScenarioOutline

Inherits:
ScenarioDefinition show all
Includes:
HasTags
Defined in:
lib/turnip/node/scenario_outline.rb

Overview

Note:

ScenarioOutline metadata generated by Gherkin

{

type: :Scenario,
tags: [], # Array of Tag
location: { line: 10, column: 3 },
keyword: "Scenario Outline",
name: "Scenario Outline Description",
steps: []

}

Instance Attribute Summary

Attributes inherited from Base

#raw

Instance Method Summary collapse

Methods included from HasTags

#metadata_hash, #tag_names, #tags

Methods inherited from ScenarioDefinition

#description, #keyword, #name, #steps

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

#examplesObject



22
23
24
25
26
# File 'lib/turnip/node/scenario_outline.rb', line 22

def examples
  @examples ||= @raw[:examples].map do |raw|
    Example.new(raw)
  end
end

#to_scenariosArray

Note:

example:

Scenario Outline: Test
  Then I go to <where>

  Examples:
    | where   |
    | bank    |
    | airport |

to

Scenario: Test
  Then I go to bank

Scenario: Test
  Then I go to airport

Return array of Scenario

Returns:

  • (Array)


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/turnip/node/scenario_outline.rb', line 53

def to_scenarios
  return [] if examples.nil?

  @scenarios ||= examples.map do |example|
    header = example.header

    example.rows.map do |row|
       = (header, row)

      #
      # Replace <placeholder> using Example values
      #
      [:steps].each do |step|
        step[:text] = substitute(step[:text], header, row)

        case
        when step[:doc_string]
          step[:doc_string][:content] = substitute(step[:doc_string][:content], header, row)
        when step[:data_table]
          step[:data_table][:rows].map do |table_row|
            table_row[:cells].map do |cell|
              cell[:value] = substitute(cell[:value], header, row)
            end
          end
        end
      end

      Scenario.new()
    end
  end.flatten.compact
end