Sha256: bbe4b4926a5ae333d456f4c3bad31417183308321cc2ba4499f6e8cc4562a77c

Contents?: true

Size: 931 Bytes

Versions: 20

Compression:

Stored size: 931 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|
              filter_location.match?(test_case.location)
            }
          }.flatten.uniq
        end

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

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core/test/filters/locations_filter.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core/test/filters/locations_filter.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core/test/filters/locations_filter.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-11.0.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-10.1.1 lib/cucumber/core/test/filters/locations_filter.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/cucumber-core-10.1.0/lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-10.1.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-10.0.1 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-10.0.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-9.0.1 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-9.0.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-8.0.1 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-7.1.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-7.0.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-6.0.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-5.0.2 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-5.0.1 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-5.0.0 lib/cucumber/core/test/filters/locations_filter.rb
cucumber-core-4.0.0 lib/cucumber/core/test/filters/locations_filter.rb