Class: Cucumber::Formatter::Rerun

Inherits:
Ast::Visitor show all
Defined in:
lib/cucumber/formatter/rerun.rb

Overview

This formatter keeps track of all failing features and print out their location. Example:

features/foo.feature:34 features/bar.feature:11:76:81

This formatter is used by AutoTest - it will use the output to decide what to run the next time, simply passing the output string on the command line.

Instance Attribute Summary

Attributes inherited from Ast::Visitor

#options, #step_mother

Instance Method Summary collapse

Methods inherited from Ast::Visitor

#announce, #matches_scenario_names?, #visit_background, #visit_background_name, #visit_comment, #visit_comment_line, #visit_examples, #visit_examples_array, #visit_examples_name, #visit_exception, #visit_feature, #visit_feature_name, #visit_multiline_arg, #visit_outline_table, #visit_py_string, #visit_scenario_name, #visit_step, #visit_step_result, #visit_steps, #visit_table_cell, #visit_table_cell_value, #visit_table_row, #visit_tag_name, #visit_tags

Constructor Details

#initialize(step_mother, io, options) ⇒ Rerun

Returns a new instance of Rerun.



12
13
14
15
16
17
18
# File 'lib/cucumber/formatter/rerun.rb', line 12

def initialize(step_mother, io, options)
  super(step_mother)
  @io = io
  @options = options
  @file_names = []
  @file_colon_lines = Hash.new{|h,k| h[k] = []}
end

Instance Method Details

#visit_feature_element(feature_element) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/cucumber/formatter/rerun.rb', line 29

def visit_feature_element(feature_element)
  @rerun = false
  super
  if @rerun
    file, line = *feature_element.file_colon_line.split(':')
    @file_colon_lines[file] << line
    @file_names << file
  end
end

#visit_features(features) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/cucumber/formatter/rerun.rb', line 20

def visit_features(features)
  super
  files = @file_names.uniq.map do |file|
    lines = @file_colon_lines[file]
    "#{file}:#{lines.join(':')}"
  end
  @io.puts files.join(' ')
end

#visit_step_name(keyword, step_match, status, source_indent, background) ⇒ Object



39
40
41
# File 'lib/cucumber/formatter/rerun.rb', line 39

def visit_step_name(keyword, step_match, status, source_indent, background)
  @rerun = true if [:failed].index(status)
end