Class: Micronaut::Formatters::BaseFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/micronaut/formatters/base_formatter.rb

Direct Known Subclasses

BaseTextFormatter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBaseFormatter

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

#behaviourObject

Returns the value of attribute behaviour.



5
6
7
# File 'lib/micronaut/formatters/base_formatter.rb', line 5

def behaviour
  @behaviour
end

#durationObject (readonly)

Returns the value of attribute duration.



6
7
8
# File 'lib/micronaut/formatters/base_formatter.rb', line 6

def duration
  @duration
end

#example_countObject (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_failedObject

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_pendingObject

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



55
56
57
# File 'lib/micronaut/formatters/base_formatter.rb', line 55

def add_behaviour(behaviour)
  @behaviour = behaviour
end

#closeObject

This method is invoked at the very end. Allows the formatter to clean up, like closing open streams.



104
105
# File 'lib/micronaut/formatters/base_formatter.rb', line 104

def close
end

#color_enabled?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/micronaut/formatters/base_formatter.rb', line 25

def color_enabled?
  configuration.color_enabled?
end

#configurationObject



13
14
15
# File 'lib/micronaut/formatters/base_formatter.rb', line 13

def configuration
  Micronaut.configuration
end

#dump_failuresObject

Dumps detailed information about each example failure.



92
93
# File 'lib/micronaut/formatters/base_formatter.rb', line 92

def dump_failures
end

#dump_pendingObject

This gets invoked after the summary if option is set to do so.



100
101
# File 'lib/micronaut/formatters/base_formatter.rb', line 100

def dump_pending
end

#dump_summaryObject

This method is invoked after the dumping of examples and failures.



96
97
# File 'lib/micronaut/formatters/base_formatter.rb', line 96

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.



72
73
74
# File 'lib/micronaut/formatters/base_formatter.rb', line 72

def example_failed(example, exception)
  @total_example_failed += 1
end

#example_passed(example) ⇒ Object

This method is invoked when an example passes.



65
66
# File 'lib/micronaut/formatters/base_formatter.rb', line 65

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



82
83
# File 'lib/micronaut/formatters/base_formatter.rb', line 82

def example_pending(example, message)
end

#example_profiling_infoObject



29
30
31
# File 'lib/micronaut/formatters/base_formatter.rb', line 29

def example_profiling_info
  @example_profiling_info ||= []
end

#example_started(example) ⇒ Object

This method is invoked when an example starts.



60
61
62
# File 'lib/micronaut/formatters/base_formatter.rb', line 60

def example_started(example)

end

#failed_examplesObject



37
38
39
# File 'lib/micronaut/formatters/base_formatter.rb', line 37

def failed_examples
  @failed_examples ||= []
end

#format_backtrace(backtrace, example) ⇒ Object



107
108
109
110
111
112
113
# File 'lib/micronaut/formatters/base_formatter.rb', line 107

def format_backtrace(backtrace, example)
  return "" unless backtrace
  return backtrace if example.[:full_backtrace] == true

  cleansed = backtrace.select { |line| backtrace_line(line) }
  cleansed.empty? ? backtrace : cleansed
end

#outputObject



17
18
19
# File 'lib/micronaut/formatters/base_formatter.rb', line 17

def output
  Micronaut.configuration.output
end

#pending_examplesObject



33
34
35
# File 'lib/micronaut/formatters/base_formatter.rb', line 33

def pending_examples
  @pending_examples ||= []
end

#profile_examples?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/micronaut/formatters/base_formatter.rb', line 21

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



47
48
49
# File 'lib/micronaut/formatters/base_formatter.rb', line 47

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),



87
88
89
# File 'lib/micronaut/formatters/base_formatter.rb', line 87

def start_dump(duration)
  @duration = duration
end