Sha256: 2dc9b7f2b8d8e5d328f71981ab2ae217470e72ab95e7435321fa3d8a9b05ba11

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'cucumber/core/filter'

module Cucumber
  module Core
    module Test
      class TagFilter < Filter.new(:filter_expressions)
        def test_case(test_case)
          test_cases << test_case
          if test_case.match_tags?(filter_expressions)
            test_case.describe_to(receiver)
          end
          self
        end

        def done
          receiver.done
          self
        end

        private

        def test_cases
          @test_cases ||= TestCases.new
        end

        class TestCases
          attr_reader :test_cases_by_tag_name
          private :test_cases_by_tag_name
          def initialize
            @test_cases_by_tag_name = Hash.new { [] }
          end

          def <<(test_case)
            test_case.tags.each do |tag|
              test_cases_by_tag_name[tag.name] += [test_case]
            end
            self
          end

          def with_tag_name(tag_name)
            test_cases_by_tag_name[tag_name]
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cucumber-core-13.0.3 lib/cucumber/core/test/filters/tag_filter.rb
cucumber-core-13.0.2 lib/cucumber/core/test/filters/tag_filter.rb
cucumber-core-13.0.1 lib/cucumber/core/test/filters/tag_filter.rb
cucumber-core-13.0.0 lib/cucumber/core/test/filters/tag_filter.rb