Sha256: 38b6c44f69b042587e9cad39ebb8c9fb76b9a524f188b04572b743d299fd74c0

Contents?: true

Size: 1.12 KB

Versions: 30

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 feature(statement, uri)
        @feature_tags = statement.tags
        @uri = uri
        @formatter.feature(statement, uri)
      end

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

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

      def examples(statement, examples_rows)
        record_tags((@feature_tags.to_a + @scenario_outline_tags.to_a + statement.tags.to_a).uniq, statement.line)
        @formatter.examples(statement, examples_rows)
      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

30 entries across 30 versions & 1 rubygems

Version Path
gherkin-2.1.5 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.5-i386-mswin32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.5-i386-mingw32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.5-universal-dotnet lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.5-java lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.4 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.4-i386-mswin32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.4-i386-mingw32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.4-universal-dotnet lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.4-java lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.3 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.3-i386-mswin32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.3-i386-mingw32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.3-universal-dotnet lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.3-java lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.2 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.2-i386-mswin32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.2-i386-mingw32 lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.2-universal-dotnet lib/gherkin/formatter/tag_count_formatter.rb
gherkin-2.1.2-java lib/gherkin/formatter/tag_count_formatter.rb