Sha256: c4ae6292403e2cdb8e86cfe1aea3072289173ba7297c3843914e1d9c15cb0c36

Contents?: true

Size: 936 Bytes

Versions: 3

Compression:

Stored size: 936 Bytes

Contents

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

3 entries across 3 versions & 1 rubygems

Version Path
cucumber-core-1.5.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-1.4.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-1.3.1 lib/cucumber/core/test/filters/locations_filter.rb