Sha256: 4a2c22527bae105128e106022c09c88300ccaa819c3ea8fa7f39bae4aac52c11

Contents?: true

Size: 1.59 KB

Versions: 38

Compression:

Stored size: 1.59 KB

Contents

require 'gherkin/tag_expression'

module ParallelTests
  module Cucumber
    module Formatters
      class ScenarioLineLogger
        attr_reader :scenarios

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

        def visit_feature_element(feature_element)
          return unless @tag_expression.evaluate(feature_element.source_tags)

          case feature_element
          when ::Cucumber::Ast::Scenario
            line = if feature_element.respond_to?(:line)
              feature_element.line
            else
              feature_element.instance_variable_get(:@line)
            end
            @scenarios << [feature_element.feature.file, line].join(":")
          when ::Cucumber::Ast::ScenarioOutline
            sections = feature_element.instance_variable_get(:@example_sections)
            sections.each { |section|
              rows = if section[1].respond_to?(:rows)
                section[1].rows
              else
                section[1].instance_variable_get(:@rows)
              end
              rows.each_with_index { |row, index|
                next if index == 0  # slices didn't work with jruby data structure
                line = if row.respond_to?(:line)
                  row.line
                else
                  row.instance_variable_get(:@line)
                end
                @scenarios << [feature_element.feature.file, line].join(":")
              }
            }
          end
        end

        def method_missing(*args)
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
parallel_tests-1.5.1 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.5.0 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.3.9 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.3.8 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.3.7 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.3.6 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.3.5 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.3.4 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.3.3 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.3.2 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.3.1 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.3.0 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.2.0 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.1.1 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.0.9 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.0.8 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.0.7 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.0.6 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.0.5 lib/parallel_tests/cucumber/scenario_line_logger.rb
parallel_tests-1.0.4 lib/parallel_tests/cucumber/scenario_line_logger.rb