4 # Baseclass for formatters that implements all required methods as no-ops.
6 attr_accessor :example_group, :options, :where
7 def initialize(options, where)
12 # This method is invoked before any examples are run, right after
13 # they have all been collected. This can be useful for special
14 # formatters that need to provide progress on feedback (graphical ones)
16 # This method will only be invoked once, and the next one to be invoked
17 # is #add_example_group
18 def start(example_count)
21 # This method is invoked at the beginning of the execution of each example_group.
22 # +name+ is the name of the example_group and +first+ is true if it is the
23 # first example_group - otherwise it's false.
25 # The next method to be invoked after this is #example_failed or #example_finished
26 def add_example_group(example_group)
27 @example_group = example_group
30 # This method is invoked when an +example+ starts.
31 def example_started(example)
34 # This method is invoked when an +example+ passes.
35 def example_passed(example)
38 # This method is invoked when an +example+ fails, i.e. an exception occurred
39 # inside it (such as a failed should or other exception). +counter+ is the
40 # sequence number of the failure (starting at 1) and +failure+ is the associated
42 def example_failed(example, counter, failure)
45 # This method is invoked when an example is not yet implemented (i.e. has not
46 # been provided a block), or when an ExamplePendingError is raised.
47 # +message+ is the message from the ExamplePendingError, if it exists, or the
48 # default value of "Not Yet Implemented"
49 def example_pending(example_group_description, example, message)
52 # This method is invoked after all of the examples have executed. The next method
53 # to be invoked after this one is #dump_failure (once for each failed example),
57 # Dumps detailed information about an example failure.
58 # This method is invoked for each failed example after all examples have run. +counter+ is the sequence number
59 # of the associated example. +failure+ is a Failure object, which contains detailed
60 # information about the failure.
61 def dump_failure(counter, failure)
64 # This method is invoked after the dumping of examples and failures.
65 def dump_summary(duration, example_count, failure_count, pending_count)
68 # This gets invoked after the summary if option is set to do so.
72 # This method is invoked at the very end. Allows the formatter to clean up, like closing open streams.