# File lib/rspec/core/formatters/base_formatter.rb, line 15 15: def initialize(output) 16: @output = output || StringIO.new 17: @example_count = @pending_count = @failure_count = 0 18: @examples = [] 19: @failed_examples = [] 20: @pending_examples = [] 21: @example_group = nil 22: end
This method is invoked at the very end. Allows the formatter to clean up, like closing open streams.
# File lib/rspec/core/formatters/base_formatter.rb, line 95 95: def close 96: restore_sync_output 97: end
Dumps detailed information about each example failure.
# File lib/rspec/core/formatters/base_formatter.rb, line 76 76: def dump_failures 77: end
This gets invoked after the summary if option is set to do so.
# File lib/rspec/core/formatters/base_formatter.rb, line 88 88: def dump_pending 89: end
This method is invoked after the dumping of examples and failures.
# File lib/rspec/core/formatters/base_formatter.rb, line 80 80: def dump_summary(duration, example_count, failure_count, pending_count) 81: @duration = duration 82: @example_count = example_count 83: @failure_count = failure_count 84: @pending_count = pending_count 85: end
# File lib/rspec/core/formatters/base_formatter.rb, line 60 60: def example_failed(example) 61: @failed_examples << example 62: end
This method is invoked at the end of the execution of each example group. example_group is the example_group.
# File lib/rspec/core/formatters/base_formatter.rb, line 46 46: def example_group_finished(example_group) 47: end
This method is invoked at the beginning of the execution of each example group. example_group is the example_group.
The next method to be invoked after this is example_passed, example_pending, or example_finished
# File lib/rspec/core/formatters/base_formatter.rb, line 40 40: def example_group_started(example_group) 41: @example_group = example_group 42: end
# File lib/rspec/core/formatters/base_formatter.rb, line 53 53: def example_passed(example) 54: end
# File lib/rspec/core/formatters/base_formatter.rb, line 56 56: def example_pending(example) 57: @pending_examples << example 58: end
# File lib/rspec/core/formatters/base_formatter.rb, line 49 49: def example_started(example) 50: examples << example 51: end
# File lib/rspec/core/formatters/base_formatter.rb, line 99 99: def format_backtrace(backtrace, example) 100: return "" unless backtrace 101: return backtrace if example.metadata[:full_backtrace] == true 102: 103: if at_exit_index = backtrace.index(RSpec::Core::Runner::AT_EXIT_HOOK_BACKTRACE_LINE) 104: backtrace = backtrace[0, at_exit_index] 105: end 106: 107: cleansed = backtrace.map { |line| backtrace_line(line) }.compact 108: cleansed.empty? ? backtrace : cleansed 109: end
# File lib/rspec/core/formatters/base_formatter.rb, line 64 64: def message(message) 65: end
# File lib/rspec/core/formatters/base_formatter.rb, line 91 91: def seed(number) 92: end
This method is invoked before any examples are run, right after they have all been collected. This can be useful for special formatters that need to provide progress on feedback (graphical ones)
This will only be invoked once, and the next one to be invoked is #
# File lib/rspec/core/formatters/base_formatter.rb, line 30 30: def start(example_count) 31: start_sync_output 32: @example_count = example_count 33: end
# File lib/rspec/core/formatters/base_formatter.rb, line 117 117: def backtrace_line(line) 118: return nil if configuration.cleaned_from_backtrace?(line) 119: RSpec::Core::Metadata::relative_path(line) 120: end
# File lib/rspec/core/formatters/base_formatter.rb, line 160 160: def color_enabled? 161: configuration.color_enabled? 162: end
# File lib/rspec/core/formatters/base_formatter.rb, line 113 113: def configuration 114: RSpec.configuration 115: end
# File lib/rspec/core/formatters/base_formatter.rb, line 136 136: def find_failed_line(backtrace, path) 137: path = File.expand_path(path) 138: backtrace.detect { |line| 139: match = line.match(/(.+?):(\d+)(|:\d+)/) 140: match && match[1].downcase == path.downcase 141: } 142: end
# File lib/rspec/core/formatters/base_formatter.rb, line 152 152: def output_supports_sync 153: output.respond_to?(:sync=) 154: end
# File lib/rspec/core/formatters/base_formatter.rb, line 156 156: def profile_examples? 157: configuration.profile_examples 158: end
# File lib/rspec/core/formatters/base_formatter.rb, line 122 122: def read_failed_line(exception, example) 123: unless matching_line = find_failed_line(exception.backtrace, example.file_path) 124: return "Unable to find matching line from backtrace" 125: end 126: 127: file_path, line_number = matching_line.match(/(.+?):(\d+)(|:\d+)/)[1..2] 128: 129: if File.exist?(file_path) 130: File.readlines(file_path)[line_number.to_i - 1] 131: else 132: "Unable to find #{file_path} to read failed line" 133: end 134: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.