123456789_123456789_123456789_123456789_123456789_

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

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: RSpec::Core::Formatters::BaseTextFormatter
Defined in: rspec-core/lib/rspec/core/formatters/documentation_formatter.rb

Class Method Summary

BaseFormatter - Inherited

Instance Attribute Summary

Instance Method Summary

BaseTextFormatter - Inherited

#close

Invoked at the end of a suite run.

#dump_failures

Dumps detailed information about each example failure.

#dump_pending,
#dump_summary

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

#message

Used by the reporter to send messages to the output stream.

#seed

BaseFormatter - Inherited

Instance Method Details

#current_indentation(offset = 0) (private)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/documentation_formatter.rb', line 96

def current_indentation(offset=0)
  '  ' * (@group_level + offset)
end

#example_failed(failure)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/documentation_formatter.rb', line 50

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

  flush_messages
  @example_running = false
end

#example_group_finished(_notification)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/documentation_formatter.rb', line 31

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

#example_group_started(notification)

[ GitHub ]

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

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)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/documentation_formatter.rb', line 35

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

  flush_messages
  @example_running = false
end

#example_pending(pending)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/documentation_formatter.rb', line 42

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

  flush_messages
  @example_running = false
end

#example_started(_notification)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/documentation_formatter.rb', line 20

def example_started(_notification)
  @example_running = true
end

#failure_output(example) (private)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/documentation_formatter.rb', line 85

def failure_output(example)
  ConsoleCodes.wrap("#{current_indentation}#{example.description.strip} " \
                    "(FAILED - #{next_failure_index})",
                    :failure)
end

#flush_messages (private)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/documentation_formatter.rb', line 67

def flush_messages
  @messages.each do |message|
    output.puts "#{current_indentation(1)}#{message}"
  end

  @messages.clear
end

#message(notification)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/documentation_formatter.rb', line 57

def message(notification)
  if @example_running
    @messages << notification.message
  else
    output.puts "#{current_indentation}#{notification.message}"
  end
end

#next_failure_index (private)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/documentation_formatter.rb', line 91

def next_failure_index
  @next_failure_index ||= 0
  @next_failure_index += 1
end

#passed_output(example) (private)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/documentation_formatter.rb', line 75

def passed_output(example)
  ConsoleCodes.wrap("#{current_indentation}#{example.description.strip}", :success)
end

#pending_output(example, message) (private)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/documentation_formatter.rb', line 79

def pending_output(example, message)
  ConsoleCodes.wrap("#{current_indentation}#{example.description.strip} " \
                    "(PENDING: #{message})",
                    :pending)
end