Class: ParallelTests::Cucumber::FeaturesWithSteps

Inherits:
Object
  • Object
show all
Defined in:
lib/parallel_tests/cucumber/features_with_steps.rb

Class Method Summary collapse

Class Method Details

.all(tests, options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/parallel_tests/cucumber/features_with_steps.rb', line 13

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