class Croaky::RSpec::CroakyFormatter

Croaky formatter

Constants

COLORIZER
NOTIFICATIONS

Attributes

io_stream[R]

Public Class Methods

new(output, io_stream = ::Croaky::Builders.io_stream) click to toggle source
Calls superclass method
# File lib/croaky/rspec/croaky_formatter.rb, line 20
def initialize(output, io_stream = ::Croaky::Builders.io_stream)
  super(output)

  @io_stream = io_stream
end

Public Instance Methods

dump_failures(notification) click to toggle source

@param [RSpec::Core::Notifications::ExamplesNotification] notification

# File lib/croaky/rspec/croaky_formatter.rb, line 59
def dump_failures(notification)
  return if notification.failure_notifications.empty?

  output.puts
  output.puts 'Failures:'
  notification.failure_notifications.each_with_index do |failure, index|
    output.puts failure.fully_formatted(index.next, COLORIZER)
    output.puts failure.example.captured_io
  end
end
example_failed(notification) click to toggle source

@param [RSpec::Core::Notifications::FailedExampleNotification] notification

# File lib/croaky/rspec/croaky_formatter.rb, line 47
def example_failed(notification)
  io_stream.restore_io

  class << notification.example
    attr_accessor :captured_io
  end

  notification.example.captured_io = io_stream.read_captured_io
  output.print COLORIZER.wrap('F', :failure)
end
example_passed(_notification) click to toggle source
# File lib/croaky/rspec/croaky_formatter.rb, line 36
def example_passed(_notification)
  io_stream.restore_io
  output.print COLORIZER.wrap('.', :success)
end
example_pending(_notification) click to toggle source
# File lib/croaky/rspec/croaky_formatter.rb, line 41
def example_pending(_notification)
  io_stream.restore_io
  output.print COLORIZER.wrap('*', :pending)
end
example_started(_notification) click to toggle source
# File lib/croaky/rspec/croaky_formatter.rb, line 32
def example_started(_notification)
  io_stream.capture_io
end
start(notification) click to toggle source
Calls superclass method
# File lib/croaky/rspec/croaky_formatter.rb, line 26
def start(notification)
  super(notification)

  io_stream.capture_io
end