Sha256: 33c514b9683b70729d0df0a2f72c31727c92c4ef8810eb68ff214fb0e5f9faea

Contents?: true

Size: 904 Bytes

Versions: 2

Compression:

Stored size: 904 Bytes

Contents

module CukeIterations
  class ScenarioExtractingFormatter
    attr_reader :discovered_scenarios

    def initialize
      @discovered_scenarios = []
      @feature_tags = []
    end

    def feature(feature)
      @feature_tags = feature.tags.map { |t| t.name }
    end

    def scenario(scenario)
      @discovered_scenarios << {
          line: scenario.line,
          tags: @feature_tags + scenario.tags.map { |t| t.name }
      }
    end

    def scenario_outline(outline)
      @outline_tags = outline.tags.map { |t| t.name }
    end

    def examples(examples)
      examples.rows.each do |row|
        next if row == examples.rows.first

        @discovered_scenarios << {
            line: row.line,
            tags: @feature_tags + @outline_tags + examples.tags.map { |t| t.name }
        }
      end
    end

    def method_missing(sym, *args, &block)
      # We don't care
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cuke_iterations-0.0.2 lib/cuke_iterations/scenario_extracting_formatter.rb
cuke_iterations-0.0.1 lib/cuke_iterations/scenario_extracting_formatter.rb