changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/lib/spec/runner/formatter/base_formatter.rb

changeset 15: 64acf98d15f4
author: moriq@moriq.com
date: Mon Mar 10 10:12:58 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec
1module Spec
2 module Runner
3 module Formatter
4 # Baseclass for formatters that implements all required methods as no-ops.
5 class BaseFormatter
6 attr_accessor :example_group, :options, :where
7 def initialize(options, where)
8 @options = options
9 @where = where
10 end
11
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)
15 #
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)
19 end
20
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.
24 #
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
28 end
29
30 # This method is invoked when an +example+ starts.
31 def example_started(example)
32 end
33
34 # This method is invoked when an +example+ passes.
35 def example_passed(example)
36 end
37
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
41 # Failure object.
42 def example_failed(example, counter, failure)
43 end
44
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)
50 end
51
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),
54 def start_dump
55 end
56
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)
62 end
63
64 # This method is invoked after the dumping of examples and failures.
65 def dump_summary(duration, example_count, failure_count, pending_count)
66 end
67
68 # This gets invoked after the summary if option is set to do so.
69 def dump_pending
70 end
71
72 # This method is invoked at the very end. Allows the formatter to clean up, like closing open streams.
73 def close
74 end
75 end
76 end
77 end
78end