Class: ParallelTests::Cucumber::Formatters::ScenarioLineLogger

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag_expression = ::Gherkin::TagExpression.new([])) ⇒ ScenarioLineLogger

Returns a new instance of ScenarioLineLogger.



9
10
11
12
13
# File 'lib/parallel_tests/cucumber/scenario_line_logger.rb', line 9

def initialize(tag_expression = ::Gherkin::TagExpression.new([]))
  raise "ScenarioLineLogger not supported anymore after upgrading to Cucumber 2.0, please fix!"
  @scenarios = []
  @tag_expression = tag_expression
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



47
48
# File 'lib/parallel_tests/cucumber/scenario_line_logger.rb', line 47

def method_missing(*args)
end

Instance Attribute Details

#scenariosObject (readonly)

Returns the value of attribute scenarios.



7
8
9
# File 'lib/parallel_tests/cucumber/scenario_line_logger.rb', line 7

def scenarios
  @scenarios
end

Instance Method Details

#visit_feature_element(feature_element) ⇒ Object



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
# File 'lib/parallel_tests/cucumber/scenario_line_logger.rb', line 15

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