Sha256: 27bdf7c76e224e95b51a3168b776ff940fa2493be0b5e62e200126d843e0f5a2

Contents?: true

Size: 1.12 KB

Versions: 386

Compression:

Stored size: 1.12 KB

Contents

module Gherkin
  module Formatter
    class TagCountFormatter
      def initialize(formatter, tag_counts)
        @formatter = formatter
        @tag_counts = tag_counts
      end

      def uri(uri)
        @uri = uri
      end

      def feature(feature)
        @feature_tags = feature.tags
        @formatter.feature(feature)
      end

      def scenario(scenario)
        record_tags((@feature_tags.to_a + scenario.tags.to_a).uniq, scenario.line)
        @formatter.scenario(scenario)
      end

      def scenario_outline(scenario_outline)
        @scenario_outline_tags = scenario_outline.tags
        @formatter.scenario_outline(scenario_outline)
      end

      def examples(examples)
        record_tags((@feature_tags.to_a + @scenario_outline_tags.to_a + examples.tags.to_a).uniq, examples.line)
        @formatter.examples(examples)
      end

    private

      def record_tags(tags, line)
        tags.each do |tag|
          @tag_counts[tag.name] ||= []
          @tag_counts[tag.name] << "#{@uri}:#{line}"
        end
      end

      def method_missing(*args)
        @formatter.__send__(*args)
      end
    end
  end
end

Version data entries

386 entries across 379 versions & 11 rubygems

Version Path
gherkin-2.2.1-java lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.2.0 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.2.0-i386-mswin32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.2.0-i386-mingw32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.2.0-universal-dotnet lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.2.0-java lib/gherkin/formatter/tag_count_formatter.rb