Sha256: ea049ab125677dbda5a4460fb41b202a268c052980f5723e37e35170ec397bdb

Contents?: true

Size: 860 Bytes

Versions: 6

Compression:

Stored size: 860 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(:locations)

        def test_case(test_case)
          test_cases << 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
          locations.map { |location| test_cases_matching(location) }.flatten
        end

        def test_cases_matching(location)
          test_cases.select do |test_case|
            test_case.match_locations?([location])
          end
        end

        def test_cases
          @test_cases ||= []
        end

      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cucumber-core-1.3.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-1.2.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-1.1.3 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-1.1.2 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-1.1.1 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-1.1.0 lib/cucumber/core/test/filters/locations_filter.rb