Parent

Included Modules

Class Index [+]

Quicksearch

RSpec::Core::Formatters::BaseFormatter

Attributes

example_group[RW]
duration[R]
examples[R]
output[R]
example_count[R]
pending_count[R]
failure_count[R]
failed_examples[R]
pending_examples[R]

Public Class Methods

new(output) click to toggle source
    # 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

Public Instance Methods

close() click to toggle source

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
dump_failures() click to toggle source

Dumps detailed information about each example failure.

    # File lib/rspec/core/formatters/base_formatter.rb, line 76
76:         def dump_failures
77:         end
dump_pending() click to toggle source

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
dump_summary(duration, example_count, failure_count, pending_count) click to toggle source

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
example_failed(example) click to toggle source
    # File lib/rspec/core/formatters/base_formatter.rb, line 60
60:         def example_failed(example)
61:           @failed_examples << example
62:         end
example_group_finished(example_group) click to toggle source

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
example_group_started(example_group) click to toggle source

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
example_passed(example) click to toggle source
    # File lib/rspec/core/formatters/base_formatter.rb, line 53
53:         def example_passed(example)
54:         end
example_pending(example) click to toggle source
    # File lib/rspec/core/formatters/base_formatter.rb, line 56
56:         def example_pending(example)
57:           @pending_examples << example
58:         end
example_started(example) click to toggle source
    # File lib/rspec/core/formatters/base_formatter.rb, line 49
49:         def example_started(example)
50:           examples << example
51:         end
format_backtrace(backtrace, example) click to toggle source
     # 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
message(message) click to toggle source
    # File lib/rspec/core/formatters/base_formatter.rb, line 64
64:         def message(message)
65:         end
seed(number) click to toggle source
    # File lib/rspec/core/formatters/base_formatter.rb, line 91
91:         def seed(number)
92:         end
start(example_count) click to toggle source

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
start_dump() click to toggle source

This method is invoked after all of the examples have executed. The next method to be invoked after this one is # (once for each failed example),

    # File lib/rspec/core/formatters/base_formatter.rb, line 72
72:         def start_dump
73:         end
stop() click to toggle source
    # File lib/rspec/core/formatters/base_formatter.rb, line 67
67:         def stop
68:         end

Protected Instance Methods

backtrace_line(line) click to toggle source
     # 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
color_enabled?() click to toggle source
     # File lib/rspec/core/formatters/base_formatter.rb, line 160
160:         def color_enabled?
161:           configuration.color_enabled?
162:         end
configuration() click to toggle source
     # File lib/rspec/core/formatters/base_formatter.rb, line 113
113:         def configuration
114:           RSpec.configuration
115:         end
find_failed_line(backtrace, path) click to toggle source
     # 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
output_supports_sync() click to toggle source
     # File lib/rspec/core/formatters/base_formatter.rb, line 152
152:         def output_supports_sync
153:           output.respond_to?(:sync=)
154:         end
profile_examples?() click to toggle source
     # File lib/rspec/core/formatters/base_formatter.rb, line 156
156:         def profile_examples?
157:           configuration.profile_examples
158:         end
read_failed_line(exception, example) click to toggle source
     # 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
restore_sync_output() click to toggle source
     # File lib/rspec/core/formatters/base_formatter.rb, line 148
148:         def restore_sync_output
149:           output.sync = @old_sync if output_supports_sync and !output.closed?
150:         end
start_sync_output() click to toggle source
     # File lib/rspec/core/formatters/base_formatter.rb, line 144
144:         def start_sync_output
145:           @old_sync, output.sync = output.sync, true if output_supports_sync
146:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.