Class: Cucumber::Formatter::Rerun

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

Overview

The formatter used for --format rerun

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, #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.



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

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



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

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



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

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



41
42
43
# File 'lib/cucumber/formatter/rerun.rb', line 41

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