class AvocadoFormatter::RSpec3

Attributes

failed_notifications[R]

See avocado_formatter.rb for formatter registration.

output[R]

See avocado_formatter.rb for formatter registration.

Public Class Methods

new(output) click to toggle source
# File lib/avocado_formatter/rspec3.rb, line 9
def initialize(output)
  @output = output
  @group_level = 0
  @index_offset = 0
  @failed_notifications = []

  @hostname = 'localhost'
  @port = '1336'
  @socket = TCPSocket.open(@hostname, @port)
end

Public Instance Methods

color() click to toggle source
# File lib/avocado_formatter/rspec3.rb, line 20
def color
  unless defined?(::RSpec::Core::Formatters::ConsoleCodes)
    require 'rspec/core/formatters/console_codes'
  end
  ::RSpec::Core::Formatters::ConsoleCodes
end
dump_summary(summary) click to toggle source
# File lib/avocado_formatter/rspec3.rb, line 65
def dump_summary(summary)
  output.puts summary.fully_formatted
end
example_failed(notification) click to toggle source
# File lib/avocado_formatter/rspec3.rb, line 35
def example_failed(notification)
  @failed_notifications << notification
  @socket.puts('failed');
end
example_group_finished(event) click to toggle source
# File lib/avocado_formatter/rspec3.rb, line 49
def example_group_finished(event)
  @group_level -= 1

  if @group_level.zero?
    # print_elapsed_time output, @start_time
    # output.puts

    failed_notifications.each_with_index do |failure, index|
      @socket.puts failure.fully_formatted(@index_offset + index + 1)
    end

    @index_offset += failed_notifications.size
    failed_notifications.clear
  end
end
example_group_started(event) click to toggle source
# File lib/avocado_formatter/rspec3.rb, line 40
def example_group_started(event)
  if @group_level.zero?
    @socket.print "#{event.group.description} "
    @start_time = Time.now
  end

  @group_level += 1
end
example_passed(notification) click to toggle source
# File lib/avocado_formatter/rspec3.rb, line 27
def example_passed(notification)
  @socket.puts('passed');
end
example_pending(notification) click to toggle source
# File lib/avocado_formatter/rspec3.rb, line 31
def example_pending(notification)
  @socket.puts('pending');
end
message(notification) click to toggle source
# File lib/avocado_formatter/rspec3.rb, line 74
def message(notification)
  output.puts notification.message
end
seed(notification) click to toggle source
# File lib/avocado_formatter/rspec3.rb, line 69
def seed(notification)
  return unless notification.seed_used?
  output.puts notification.fully_formatted
end