Class: Micronaut::Formatters::BaseFormatter
- Defined in:
- lib/micronaut/formatters/base_formatter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#behaviour ⇒ Object
Returns the value of attribute behaviour.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#example_count ⇒ Object
readonly
Returns the value of attribute example_count.
-
#total_example_failed ⇒ Object
Returns the value of attribute total_example_failed.
-
#total_example_pending ⇒ Object
Returns the value of attribute total_example_pending.
Instance Method Summary collapse
-
#add_behaviour(behaviour) ⇒ Object
This method is invoked at the beginning of the execution of each behaviour.
-
#close ⇒ Object
This method is invoked at the very end.
- #color_enabled? ⇒ Boolean
- #configuration ⇒ Object
-
#dump_failures ⇒ Object
Dumps detailed information about each example failure.
-
#dump_pending ⇒ Object
This gets invoked after the summary if option is set to do so.
-
#dump_summary ⇒ Object
This method is invoked after the dumping of examples and failures.
-
#example_failed(example, exception) ⇒ Object
This method is invoked when an
examplefails, i.e. -
#example_passed(example) ⇒ Object
This method is invoked when an
examplepasses. -
#example_pending(example, message) ⇒ 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_profiling_info ⇒ Object
-
#example_started(example) ⇒ Object
This method is invoked when an
examplestarts. - #failed_examples ⇒ Object
- #format_backtrace(backtrace, example) ⇒ Object
-
#initialize ⇒ BaseFormatter
constructor
A new instance of BaseFormatter.
- #output ⇒ Object
- #pending_examples ⇒ Object
- #profile_examples? ⇒ Boolean
-
#start(example_count) ⇒ Object
This method is invoked before any examples are run, right after they have all been collected.
-
#start_dump(duration) ⇒ Object
This method is invoked after all of the examples have executed.
- #trace(&blk) ⇒ Object
-
#trace_override_flag ⇒ Object
Allow setting trace at the behaviour level as well globally.
Constructor Details
#initialize ⇒ BaseFormatter
Returns a new instance of BaseFormatter.
8 9 10 11 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 8 def initialize @total_example_failed, @total_example_pending, @example_count = 0, 0, 0 @behaviour = nil end |
Instance Attribute Details
#behaviour ⇒ Object
Returns the value of attribute behaviour.
5 6 7 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 5 def behaviour @behaviour end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
6 7 8 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 6 def duration @duration end |
#example_count ⇒ Object (readonly)
Returns the value of attribute example_count.
6 7 8 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 6 def example_count @example_count end |
#total_example_failed ⇒ Object
Returns the value of attribute total_example_failed.
5 6 7 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 5 def total_example_failed @total_example_failed end |
#total_example_pending ⇒ Object
Returns the value of attribute total_example_pending.
5 6 7 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 5 def total_example_pending @total_example_pending end |
Instance Method Details
#add_behaviour(behaviour) ⇒ Object
This method is invoked at the beginning of the execution of each behaviour. behaviour is the behaviour.
The next method to be invoked after this is #example_failed or #example_finished
64 65 66 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 64 def add_behaviour(behaviour) @behaviour = behaviour end |
#close ⇒ Object
This method is invoked at the very end. Allows the formatter to clean up, like closing open streams.
112 113 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 112 def close end |
#color_enabled? ⇒ Boolean
34 35 36 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 34 def color_enabled? configuration.color_enabled? end |
#configuration ⇒ Object
13 14 15 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 13 def configuration Micronaut.configuration end |
#dump_failures ⇒ Object
Dumps detailed information about each example failure.
100 101 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 100 def dump_failures end |
#dump_pending ⇒ Object
This gets invoked after the summary if option is set to do so.
108 109 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 108 def dump_pending end |
#dump_summary ⇒ Object
This method is invoked after the dumping of examples and failures.
104 105 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 104 def dump_summary end |
#example_failed(example, exception) ⇒ Object
This method is invoked when an example fails, i.e. an exception occurred inside it (such as a failed should or other exception). counter is the sequence number of the failure (starting at 1) and failure is the associated exception.
80 81 82 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 80 def example_failed(example, exception) @total_example_failed += 1 end |
#example_passed(example) ⇒ Object
This method is invoked when an example passes.
73 74 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 73 def example_passed(example) end |
#example_pending(example, message) ⇒ 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” pending_caller is the file and line number of the spec which has called the pending method
90 91 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 90 def example_pending(example, ) end |
#example_profiling_info ⇒ Object
38 39 40 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 38 def example_profiling_info @example_profiling_info ||= [] end |
#example_started(example) ⇒ Object
This method is invoked when an example starts.
69 70 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 69 def example_started(example) end |
#failed_examples ⇒ Object
46 47 48 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 46 def failed_examples @failed_examples ||= [] end |
#format_backtrace(backtrace, example) ⇒ Object
115 116 117 118 119 120 121 122 123 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 115 def format_backtrace(backtrace, example) return "" unless backtrace return backtrace if example.[:full_backtrace] == true cleansed = backtrace.select { |line| backtrace_line(line) } # Kick the describe stack info off the list, just keep the line the problem happened on from that file # cleansed = [cleansed.detect { |line| line.split(':').first == example.metadata[:caller].split(':').first }] if cleansed.size > 1 cleansed.empty? ? backtrace : cleansed end |
#output ⇒ Object
17 18 19 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 17 def output Micronaut.configuration.output end |
#pending_examples ⇒ Object
42 43 44 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 42 def pending_examples @pending_examples ||= [] end |
#profile_examples? ⇒ Boolean
30 31 32 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 30 def profile_examples? Micronaut.configuration.profile_examples 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 #add_behaviour
56 57 58 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 56 def start(example_count) @example_count = example_count end |
#start_dump(duration) ⇒ 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),
95 96 97 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 95 def start_dump(duration) @duration = duration end |
#trace(&blk) ⇒ Object
21 22 23 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 21 def trace(&blk) Micronaut.configuration.trace(trace_override_flag, &blk) end |
#trace_override_flag ⇒ Object
Allow setting trace at the behaviour level as well globally
26 27 28 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 26 def trace_override_flag behaviour && behaviour.[:trace] end |