Sha256: 687ccc51bc749b5b3ac0c8faf6acd27137c515ca10d538fbee4521b4c7dfec4f

Contents?: true

Size: 966 Bytes

Versions: 7

Compression:

Stored size: 966 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.all_locations.any? { |location| filter_location.match?(location) }
            }
          }.flatten.uniq
        end

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

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/cucumber-core-3.2.1/lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-3.2.1 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-3.2.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-3.1.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-3.0.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-3.0.0.pre.2 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-2.0.0 lib/cucumber/core/test/filters/locations_filter.rb