Sha256: 9d534eeb87060247a2aa036944e98c677ce4186707093b74da9baf6aeccf58e3

Contents?: true

Size: 934 Bytes

Versions: 4

Compression:

Stored size: 934 Bytes

Contents

# frozen_string_literal: true
require 'cucumber/core/filter'

module Cucumber
  module Core
    module Test

      # Sorts and filters scenarios based on a list of locations
      class LocationsFilter < Filter.new(:filter_locations)

        def test_case(test_case)
          test_cases[test_case.location.file] << test_case
          self
        end

        def done
          sorted_test_cases.each do |test_case|
            test_case.describe_to receiver
          end
          receiver.done
          self
        end

        private

        def sorted_test_cases
          filter_locations.map { |filter_location|
            test_cases[filter_location.file].select { |test_case|
              test_case.match_locations?([filter_location])
            }
          }.flatten.uniq
        end

        def test_cases
          @test_cases ||= Hash.new { |hash, key| hash[key] = [] }
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/cucumber-core-12.0.0/lib/cucumber/core/test/filters/locations_filter.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/cucumber-core-11.1.0/lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-12.0.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-11.1.0 lib/cucumber/core/test/filters/locations_filter.rb