Sha256: 65e03a269ba4df7ddd3018a35c121ae3b82d96b766de1758ff549bffaed3366b

Contents?: true

Size: 1.81 KB

Versions: 19

Compression:

Stored size: 1.81 KB

Contents

require 'cucumber/core/gherkin/tag_expression'

module ParallelTests
  module Cucumber
    module Formatters
      class ScenarioLineLogger
        attr_reader :scenarios

        def initialize(tag_expression = ::Cucumber::Core::Gherkin::TagExpression.new([]))
          @scenarios = []
          @tag_expression = tag_expression
        end

        def visit_feature_element(uri, feature_element, feature_tags, line_numbers: [])
          scenario_tags = feature_element[:tags].map {|tag| ::Cucumber::Core::Ast::Tag.new(tag[:location], tag[:name])}
          scenario_tags = feature_tags + scenario_tags
          if feature_element[:examples].nil? # :Scenario
            test_line = feature_element[:location][:line]

            # We don't accept the feature_element if the current tags are not valid
            return unless @tag_expression.evaluate(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[:location][:line]].join(":")
          else # :ScenarioOutline
            feature_element[:examples].each do |example|
              example_tags = example[:tags].map {|tag| ::Cucumber::Core::Ast::Tag.new(tag[:location], tag[:name])}
              example_tags = scenario_tags + example_tags
              next unless @tag_expression.evaluate(example_tags)
              rows = example[:tableBody].select { |body| body[:type] == :TableRow }
              rows.each do |row|
                test_line = row[:location][:line]
                next if line_numbers.any? && !line_numbers.include?(test_line)

                @scenarios << [uri, test_line].join(':')
              end
            end
          end
        end

        def method_missing(*args)
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
parallel_tests-2.26.2 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.26.0 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.25.0 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.24.0 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.23.0 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.22.1 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.22.0 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.21.3 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.21.2 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.21.1 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.21.0 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.20.0 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.19.0 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.18.0 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.17.1 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.17.0 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.16.1 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.16.0 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-2.15.0 lib/parallel_tests/cucumber/scenario_line_logger.rb