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.
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
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_finished(example) ⇒ Object
- #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 12 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 8 def initialize @example_count = 0 @examples = [] @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 |
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
6 7 8 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 6 def examples @examples 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
65 66 67 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 65 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.
88 89 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 88 def close end |
#color_enabled? ⇒ Boolean
35 36 37 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 35 def color_enabled? configuration.color_enabled? end |
#configuration ⇒ Object
14 15 16 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 14 def configuration Micronaut.configuration end |
#dump_failures ⇒ Object
Dumps detailed information about each example failure.
76 77 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 76 def dump_failures end |
#dump_pending ⇒ Object
This gets invoked after the summary if option is set to do so.
84 85 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 84 def dump_pending end |
#dump_summary ⇒ Object
This method is invoked after the dumping of examples and failures.
80 81 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 80 def dump_summary end |
#example_finished(example) ⇒ Object
57 58 59 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 57 def example_finished(example) examples << example end |
#failed_examples ⇒ Object
43 44 45 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 43 def failed_examples @failed_examples ||= ::Micronaut.world.find(examples, :positive, :execution_result => { :status => 'failed' }) end |
#format_backtrace(backtrace, example) ⇒ Object
91 92 93 94 95 96 97 98 99 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 91 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
18 19 20 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 18 def output Micronaut.configuration.output end |
#pending_examples ⇒ Object
39 40 41 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 39 def pending_examples @pending_examples ||= ::Micronaut.world.find(examples, :positive, :execution_result => { :status => 'pending' }) end |
#profile_examples? ⇒ Boolean
31 32 33 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 31 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
53 54 55 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 53 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),
71 72 73 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 71 def start_dump(duration) @duration = duration end |
#trace(&blk) ⇒ Object
22 23 24 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 22 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
27 28 29 |
# File 'lib/micronaut/formatters/base_formatter.rb', line 27 def trace_override_flag behaviour && behaviour.[:trace] end |