| Class | Spec::Runner::Formatter::NestedTextFormatter |
| In: |
lib/spec/runner/formatter/nested_text_formatter.rb
|
| Parent: | BaseTextFormatter |
| previous_nested_example_groups | [R] |
# File lib/spec/runner/formatter/nested_text_formatter.rb, line 8
8: def initialize(options, where)
9: super
10: @previous_nested_example_groups = []
11: end
# File lib/spec/runner/formatter/nested_text_formatter.rb, line 13
13: def add_example_group(example_group)
14: super
15:
16: current_nested_example_groups = described_example_group_chain
17: current_nested_example_groups.each_with_index do |nested_example_group, i|
18: unless nested_example_group == previous_nested_example_groups[i]
19: output.puts "#{' ' * i}#{nested_example_group.description_args}"
20: end
21: end
22:
23: @previous_nested_example_groups = described_example_group_chain
24: end
# File lib/spec/runner/formatter/nested_text_formatter.rb, line 49
49: def current_indentation
50: ' ' * previous_nested_example_groups.length
51: end
# File lib/spec/runner/formatter/nested_text_formatter.rb, line 53
53: def described_example_group_chain
54: example_group_chain = []
55: example_group.send(:execute_in_class_hierarchy) do |parent_example_group|
56: if parent_example_group.description_args && !parent_example_group.description_args.empty?
57: example_group_chain << parent_example_group
58: end
59: end
60: example_group_chain
61: end
# File lib/spec/runner/formatter/nested_text_formatter.rb, line 26
26: def example_failed(example, counter, failure)
27: message = if failure.expectation_not_met?
28: "#{current_indentation}#{example.description} (FAILED - #{counter})"
29: else
30: "#{current_indentation}#{example.description} (ERROR - #{counter})"
31: end
32:
33: output.puts(failure.expectation_not_met? ? red(message) : magenta(message))
34: output.flush
35: end
# File lib/spec/runner/formatter/nested_text_formatter.rb, line 37
37: def example_passed(example)
38: message = "#{current_indentation}#{example.description}"
39: output.puts green(message)
40: output.flush
41: end