Class: Micronaut::Formatters::DocumentationFormatter
Instance Attribute Summary collapse
#behaviour, #duration, #example_count, #examples
Instance Method Summary
collapse
#close, #colorise, #dump_failures, #dump_pending, #dump_summary, #format_caller
#close, #color_enabled?, #configuration, #dump_failures, #dump_pending, #dump_summary, #failed_examples, #format_backtrace, #output, #pending_examples, #profile_examples?, #start, #start_dump, #trace, #trace_override_flag
Constructor Details
Returns a new instance of DocumentationFormatter.
8
9
10
11
|
# File 'lib/micronaut/formatters/documentation_formatter.rb', line 8
def initialize
super
@previous_nested_behaviours = []
end
|
Instance Attribute Details
#previous_nested_behaviours ⇒ Object
Returns the value of attribute previous_nested_behaviours.
6
7
8
|
# File 'lib/micronaut/formatters/documentation_formatter.rb', line 6
def previous_nested_behaviours
@previous_nested_behaviours
end
|
Instance Method Details
#add_behaviour(behaviour) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/micronaut/formatters/documentation_formatter.rb', line 13
def add_behaviour(behaviour)
super
described_behaviour_chain.each_with_index do |nested_behaviour, i|
unless nested_behaviour == previous_nested_behaviours[i]
at_root_level = (i == 0)
desc_or_name = at_root_level ? nested_behaviour.name : nested_behaviour.description
output.puts if at_root_level
output.puts "#{' ' * i}#{desc_or_name}"
end
end
@previous_nested_behaviours = described_behaviour_chain
end
|
#current_indentation ⇒ Object
67
68
69
|
# File 'lib/micronaut/formatters/documentation_formatter.rb', line 67
def current_indentation
' ' * previous_nested_behaviours.size
end
|
#described_behaviour_chain ⇒ Object
71
72
73
|
# File 'lib/micronaut/formatters/documentation_formatter.rb', line 71
def described_behaviour_chain
behaviour.ancestors
end
|
#example_finished(example) ⇒ Object
41
42
43
44
45
|
# File 'lib/micronaut/formatters/documentation_formatter.rb', line 41
def example_finished(example)
super
output.puts output_for(example)
output.flush
end
|
#failure_output(example, exception) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/micronaut/formatters/documentation_formatter.rb', line 47
def failure_output(example, exception)
expectation_not_met = exception.is_a?(::Micronaut::Expectations::ExpectationNotMetError)
message = if expectation_not_met
"#{current_indentation}#{example.description} (FAILED)"
else
"#{current_indentation}#{example.description} (ERROR)"
end
expectation_not_met ? red(message) : magenta(message)
end
|
#output_for(example) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/micronaut/formatters/documentation_formatter.rb', line 28
def output_for(example)
case example.execution_result[:status]
when 'failed'
failure_output(example, example.execution_result[:exception_encountered])
when 'pending'
pending_output(example, example.execution_result[:pending_message])
when 'passed'
passed_output(example)
else
red(example.execution_result[:status])
end
end
|
#passed_output(example) ⇒ Object
59
60
61
|
# File 'lib/micronaut/formatters/documentation_formatter.rb', line 59
def passed_output(example)
green("#{current_indentation}#{example.description}")
end
|
#pending_output(example, message) ⇒ Object
63
64
65
|
# File 'lib/micronaut/formatters/documentation_formatter.rb', line 63
def pending_output(example, message)
yellow("#{current_indentation}#{example.description} (PENDING: #{message})")
end
|