Sha256: b2a6e19202ea0143ab81925c7e48f3a178de535fb5ff4aebd69763db46aaacfe

Contents?: true

Size: 1.23 KB

Versions: 33

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true
begin
  gem "cuke_modeler", "~> 3.0"
  require 'cuke_modeler'
rescue LoadError
  raise 'Grouping by number of cucumber steps requires the `cuke_modeler` modeler gem with requirement `~> 3.0`. Add `gem "cuke_modeler", "~> 3.0"` to your `Gemfile`, run `bundle install` and try again.'
end

module ParallelTests
  module Cucumber
    class FeaturesWithSteps
      class << self
        def all(tests, options)
          ignore_tag_pattern = options[:ignore_tag_pattern].nil? ? nil : Regexp.compile(options[:ignore_tag_pattern])
          # format of hash will be FILENAME => NUM_STEPS
          steps_per_file = tests.each_with_object({}) do |file, steps|
            feature = ::CukeModeler::FeatureFile.new(file).feature

            # skip feature if it matches tag regex
            next if feature.tags.grep(ignore_tag_pattern).any?

            # count the number of steps in the file
            # will only include a feature if the regex does not match
            all_steps = feature.scenarios.map { |a| a.steps.count if a.tags.grep(ignore_tag_pattern).empty? }.compact
            steps[file] = all_steps.sum
          end
          steps_per_file.sort_by { |_, value| -value }
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
parallel_tests-3.10.1 lib/parallel_tests/cucumber/features_with_steps.rb
parallel_tests-3.10.0 lib/parallel_tests/cucumber/features_with_steps.rb
parallel_tests-3.9.1 lib/parallel_tests/cucumber/features_with_steps.rb
parallel_tests-3.9.0 lib/parallel_tests/cucumber/features_with_steps.rb
parallel_tests-3.8.1 lib/parallel_tests/cucumber/features_with_steps.rb
parallel_tests-3.8.0 lib/parallel_tests/cucumber/features_with_steps.rb
parallel_tests-3.7.3 lib/parallel_tests/cucumber/features_with_steps.rb
parallel_tests-3.7.1 lib/parallel_tests/cucumber/features_with_steps.rb
parallel_tests-3.7.0 lib/parallel_tests/cucumber/features_with_steps.rb
parallel_tests-3.6.0 lib/parallel_tests/cucumber/features_with_steps.rb
parallel_tests-3.5.2 lib/parallel_tests/cucumber/features_with_steps.rb
parallel_tests-3.5.1 lib/parallel_tests/cucumber/features_with_steps.rb
parallel_tests-3.5.0 lib/parallel_tests/cucumber/features_with_steps.rb