Class: Spec::Runner::Formatter::BaseFormatter
- Defined in:
- lib/spec/runner/formatter/base_formatter.rb
Overview
Formatter base-class, which implements all required methods as no-ops, with the exception
Direct Known Subclasses
Instance Method Summary collapse
-
#add_example_group(example_group_proxy) ⇒ Object
Deprecated - use example_group_started instead.
-
#close ⇒ Object
This method is invoked at the very end.
-
#dump_failure(counter, failure) ⇒ Object
Dumps detailed information about an example failure.
-
#dump_pending ⇒ Object
This gets invoked after the summary.
-
#dump_summary(duration, example_count, failure_count, pending_count) ⇒ Object
This method is invoked after the dumping of examples and failures.
-
#example_failed(example_proxy, counter, failure) ⇒ Object
This method is invoked when an
example
fails, i.e. -
#example_group_started(example_group_proxy) ⇒ Object
This method is invoked at the beginning of the execution of each example_group.
-
#example_passed(example_proxy) ⇒ Object
This method is invoked when an
example
passes. -
#example_pending(example_proxy, message, deprecated_pending_location = nil) ⇒ Object
This method is invoked when an example is not yet implemented (i.e. has not been provided a block), or when an ExamplePendingError is raised.
-
#example_started(example_proxy) ⇒ Object
This method is invoked when an
example
starts. -
#initialize(options, output) ⇒ BaseFormatter
constructor
Formatters are initialized with
options
andoutput
arguments. -
#start(example_count) ⇒ Object
This method is invoked before any examples are run, right after they have all been collected.
-
#start_dump ⇒ Object
This method is invoked after all of the examples have executed.
Constructor Details
#initialize(options, output) ⇒ BaseFormatter
Formatters are initialized with options
and output
arguments. RSpec’s built-in formatters already expect this, and any custom formatters should as well.
Parameters
- options
-
A struct containing boolean values for colour, autospec, and dry_run
- output
-
Used by RSpec’s built-in formatters to determine where to write the output. Default is
STDOUT
, otherwise a filename is expected.
Example
If you invoke the spec
command with:
--format progress:progress_report.txt
… the value of output
will be progress_report.txt. If you don’t identify an output destination, the default is STDOUT.
26 27 |
# File 'lib/spec/runner/formatter/base_formatter.rb', line 26 def initialize(, output) end |
Instance Method Details
#add_example_group(example_group_proxy) ⇒ Object
Deprecated - use example_group_started instead
51 52 53 54 |
# File 'lib/spec/runner/formatter/base_formatter.rb', line 51 def add_example_group(example_group_proxy) Spec.deprecate("BaseFormatter#add_example_group", "BaseFormatter#example_group_started") example_group_started(example_group_proxy) end |
#close ⇒ Object
This method is invoked at the very end. Allows the formatter to clean up, like closing open streams.
134 135 |
# File 'lib/spec/runner/formatter/base_formatter.rb', line 134 def close end |
#dump_failure(counter, failure) ⇒ Object
Dumps detailed information about an example failure. This method is invoked for each failed example after all examples have run. counter
is the sequence number of the associated example. failure
is a Failure object, which contains detailed information about the failure.
Parameters
- counter
-
the sequential number of this failure
- failure
-
instance of Spec::Runner::Reporter::Failure
116 117 |
# File 'lib/spec/runner/formatter/base_formatter.rb', line 116 def dump_failure(counter, failure) end |
#dump_pending ⇒ Object
This gets invoked after the summary
130 131 |
# File 'lib/spec/runner/formatter/base_formatter.rb', line 130 def dump_pending end |
#dump_summary(duration, example_count, failure_count, pending_count) ⇒ Object
This method is invoked after the dumping of examples and failures.
Parameters
- duration
-
the total time for the entire run
- example_count
-
the number of examples run
- failure_count
-
the number of examples that failed
- pending_count
-
the number of examples that are pending
126 127 |
# File 'lib/spec/runner/formatter/base_formatter.rb', line 126 def dump_summary(duration, example_count, failure_count, pending_count) end |
#example_failed(example_proxy, counter, failure) ⇒ Object
This method is invoked when an example
fails, i.e. an exception occurred inside it (such as a failed should or other exception).
Parameters
- example_proxy
-
The same instance of Spec::Example::ExampleProxy that was passed to
example_started
- counter
-
the sequential number of this failure
- failure
-
instance of Spec::Runner::Reporter::Failure
85 86 |
# File 'lib/spec/runner/formatter/base_formatter.rb', line 85 def example_failed(example_proxy, counter, failure) end |
#example_group_started(example_group_proxy) ⇒ Object
This method is invoked at the beginning of the execution of each example_group. The next method to be invoked after this is #example_started
Parameters
- example_group_proxy
-
instance of Spec::Example::ExampleGroupProxy
47 48 |
# File 'lib/spec/runner/formatter/base_formatter.rb', line 47 def example_group_started(example_group_proxy) end |
#example_passed(example_proxy) ⇒ Object
This method is invoked when an example
passes. example_proxy
is the same instance of Spec::Example::ExampleProxy that was passed to example_started
Parameters
- example_proxy
-
instance of Spec::Example::ExampleProxy
71 72 |
# File 'lib/spec/runner/formatter/base_formatter.rb', line 71 def example_passed(example_proxy) end |
#example_pending(example_proxy, message, deprecated_pending_location = nil) ⇒ Object
This method is invoked when an example is not yet implemented (i.e. has not been provided a block), or when an ExamplePendingError is raised. message
is the message from the ExamplePendingError, if it exists, or the default value of “Not Yet Implemented”. deprecated_pending_location
is deprecated - use example_proxy.location instead
Parameters
- example_proxy
-
instance of Spec::Example::ExampleProxy
- message
-
the message passed to the pending message, or an internal default
100 101 |
# File 'lib/spec/runner/formatter/base_formatter.rb', line 100 def example_pending(example_proxy, , deprecated_pending_location=nil) end |
#example_started(example_proxy) ⇒ Object
This method is invoked when an example
starts. The next method to be invoked after this is #example_passed, #example_failed, or #example_pending
Parameters
- example_proxy
-
instance of Spec::Example::ExampleProxy
62 63 |
# File 'lib/spec/runner/formatter/base_formatter.rb', line 62 def example_started(example_proxy) end |
#start(example_count) ⇒ Object
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 method will only be invoked once, and the next one to be invoked is #example_group_started
Parameters
- example_count
-
the total number of examples to be run
38 39 |
# File 'lib/spec/runner/formatter/base_formatter.rb', line 38 def start(example_count) end |
#start_dump ⇒ Object
This method is invoked after all of the examples have executed. The next method to be invoked after this one is #dump_failure (once for each failed example)
105 106 |
# File 'lib/spec/runner/formatter/base_formatter.rb', line 105 def start_dump end |