1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
# frozen_string_literal: true
module ParallelTests
module Cucumber
module Formatters
class ScenarioLineLogger
attr_reader :scenarios
def initialize(tag_expression = nil)
@scenarios = []
@tag_expression = tag_expression
end
def visit_feature_element(uri, feature_element, feature_tags, line_numbers: [])
scenario_tags = feature_element.tags.map(&:name)
scenario_tags = feature_tags + scenario_tags
if feature_element.is_a?(CukeModeler::Scenario) # :Scenario
test_line = feature_element.source_line
# We don't accept the feature_element if the current tags are not valid
return unless matches_tags?(scenario_tags)
# or if it is not at the correct location
return if line_numbers.any? && !line_numbers.include?(test_line)
@scenarios << [uri, feature_element.source_line].join(":")
else # :ScenarioOutline
feature_element.examples.each do |example|
example_tags = example.tags.map(&:name)
example_tags = scenario_tags + example_tags
next unless matches_tags?(example_tags)
example.rows[1..].each do |row|
test_line = row.source_line
next if line_numbers.any? && !line_numbers.include?(test_line)
@scenarios << [uri, test_line].join(':')
end
end
end
end
def method_missing(*); end # # rubocop:disable Style/MissingRespondToMissing
private
def matches_tags?(tags)
@tag_expression.nil? || @tag_expression.evaluate(tags)
end
end
end
end
end
|