Class | Spec::Runner::Formatter::NestedTextFormatter
In: | lib/spec/runner/formatter/nested_text_formatter.rb
Parent: | BaseTextFormatter

### Methods

add_example_group current_indentation described_example_group_chain example_failed example_passed example_pending new

### Attributes

previous_nested_example_groups | [R] |

### Public Class methods

new(options, where)

[Source]

        # 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

### Public Instance methods

add_example_group(example_group)

[Source]

        # 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

current_indentation()

[Source]

        # File lib/spec/runner/formatter/nested_text_formatter.rb, line 49
    49:         def current_indentation
    50:           '  ' * previous_nested_example_groups.length
    51:         end

described_example_group_chain()

[Source]

        # 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

example_failed(example, counter, failure)

[Source]

        # 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

example_passed(example)

[Source]

        # 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

example_pending(example, message)

[Source]

        # File lib/spec/runner/formatter/nested_text_formatter.rb, line 43
    43:         def example_pending(example, message)
    44:           super
    45:           output.puts yellow("#{current_indentation}#{example.description} (PENDING: #{message})")
    46:           output.flush
    47:         end

[Validate]