Class: RSpec::Core::Formatters::DocumentationFormatter

Inherits:
BaseTextFormatter show all
Defined in:
lib/rspec/core/formatters/documentation_formatter.rb

Instance Attribute Summary

Attributes inherited from BaseFormatter

#example_group, #output

Instance Method Summary collapse

Methods inherited from BaseTextFormatter

#close, #dump_failures, #dump_pending, #dump_summary, #message, #seed

Methods inherited from BaseFormatter

#close, #start

Constructor Details

#initialize(output) ⇒ DocumentationFormatter

Returns a new instance of DocumentationFormatter



12
13
14
15
# File 'lib/rspec/core/formatters/documentation_formatter.rb', line 12

def initialize(output)
  super
  @group_level = 0
end

Instance Method Details

#example_failed(failure) ⇒ Object



37
38
39
# File 'lib/rspec/core/formatters/documentation_formatter.rb', line 37

def example_failed(failure)
  output.puts failure_output(failure.example)
end

#example_group_finished(_notification) ⇒ Object



24
25
26
# File 'lib/rspec/core/formatters/documentation_formatter.rb', line 24

def example_group_finished(_notification)
  @group_level -= 1 if @group_level > 0
end

#example_group_started(notification) ⇒ Object



17
18
19
20
21
22
# File 'lib/rspec/core/formatters/documentation_formatter.rb', line 17

def example_group_started(notification)
  output.puts if @group_level == 0
  output.puts "#{current_indentation}#{notification.group.description.strip}"

  @group_level += 1
end

#example_passed(passed) ⇒ Object



28
29
30
# File 'lib/rspec/core/formatters/documentation_formatter.rb', line 28

def example_passed(passed)
  output.puts passed_output(passed.example)
end

#example_pending(pending) ⇒ Object



32
33
34
35
# File 'lib/rspec/core/formatters/documentation_formatter.rb', line 32

def example_pending(pending)
  output.puts pending_output(pending.example,
                             pending.example.execution_result.pending_message)
end