Sha256: aa6fd3604eb745020d4e34123b0fa582eaa1201fd50c52acdcf3a38fa0253ea2

Contents?: true

Size: 874 Bytes

Versions: 3

Compression:

Stored size: 874 Bytes

Contents

require 'turnip/node/scenario_group_definition'

module Turnip
  module Node
    #
    # @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
    #     }
    #
    class Rule < ScenarioGroupDefinition
      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
turnip-4.3.0 lib/turnip/node/rule.rb
turnip-4.2.0 lib/turnip/node/rule.rb
turnip-4.1.0 lib/turnip/node/rule.rb