Sha256: 5f7abd11f890c339869a8707e8d848caa8223cf879fa402cd86b5fdd4aa94c36

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

module CucumberAnalytics
  class ParsedScenarioOutline < TestElement


    attr_accessor :tags
    attr_accessor :examples

    # Creates a new ParsedScenarioOutline object and, if *source_lines* is
    # provided, populates the object.
    def initialize(source_lines = nil)
      super

      @tags = []
      @examples = []

      parse_outline(source_lines) if source_lines
    end

    def contains
      @examples
    end


    private


    def parse_outline(source_lines)
      parse_feature_element_tags(source_lines)
      parse_feature_element(source_lines)
      parse_test_element_steps(source_lines)
      parse_outline_examples(source_lines)
    end

    def parse_outline_examples(source_lines)
      until source_lines.empty?
        current_example_line = source_lines.index { |line| line =~ /^\s*Examples/ }

        example_lines = source_lines.slice!(0..current_example_line)

        next_example_line = source_lines.index { |line| line =~ /^\s*Examples:/ }

        if next_example_line.nil?
          example_lines.concat(source_lines.slice!(0..source_lines.count))
        else
          while  source_lines[next_example_line - 1] =~ /^\s*@/
            next_example_line -= 1
          end

          example_lines.concat(source_lines.slice!(0...next_example_line))
        end

        @examples << OutlineExample.new(example_lines)
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cucumber_analytics-0.0.1 lib/cucumber_analytics/parsed_scenario_outline.rb