class TOTS::Printer

Generic printer

Constants

BLUE
GREEN
GREY
MARGETA
RED
VIOLET
YELLOW

Public Class Methods

method_missing(*args) click to toggle source
# File lib/tots/printer.rb, line 19
def self.method_missing(*args)
  @inst ||= (@klass || Dots).new

  @inst.__send__(*args)
end
new() click to toggle source
# File lib/tots/printer.rb, line 25
def initialize
  @suites_count  = 0
  @tests_count   = 0
  @asserts_count = 0
  @passed_count  = 0
  @fails_count   = 0
  @errors_count  = 0
  @skipped_count = 0

  print "\n"
end
set(name) click to toggle source
# File lib/tots/printer.rb, line 15
def self.set(name)
  @klass = const_get(name[0].upcase + name.slice(1, name.size - 1))
end

Public Instance Methods

asserting(msg) click to toggle source
# File lib/tots/printer.rb, line 89
def asserting(msg)
  @asserts_count += 1
end
error() click to toggle source
# File lib/tots/printer.rb, line 49
def error
  raise "Should be implemented in a subclass"
end
errored(e) click to toggle source
# File lib/tots/printer.rb, line 103
def errored(e)
  @errors_count += 1
  error(e)
end
fail() click to toggle source
# File lib/tots/printer.rb, line 45
def fail
  raise "Should be implemented in a subclass"
end
failed(e) click to toggle source
# File lib/tots/printer.rb, line 98
def failed(e)
  @fails_count += 1
  fail(e)
end
finish() click to toggle source
# File lib/tots/printer.rb, line 113
def finish
  summary
end
highlight(string, color) click to toggle source
# File lib/tots/printer.rb, line 75
def highlight(string, color)
  "\e[4#{color}m#{string}\e[0m"
end
paint(string, color) click to toggle source
# File lib/tots/printer.rb, line 71
def paint(string, color)
  "\e[3#{color}m#{string}\e[0m"
end
pass() click to toggle source
# File lib/tots/printer.rb, line 37
def pass
  raise "Should be implemented in a subclass"
end
passed() click to toggle source
# File lib/tots/printer.rb, line 93
def passed
  @passed_count += 1
  pass
end
running(test) click to toggle source
# File lib/tots/printer.rb, line 85
def running(test)
  @tests_count += 1
end
skip() click to toggle source
# File lib/tots/printer.rb, line 41
def skip
  raise "Should be implemented in a subclass"
end
skipped() click to toggle source
# File lib/tots/printer.rb, line 108
def skipped
  @skipped_count += 1
  skip
end
summary() click to toggle source
# File lib/tots/printer.rb, line 53
def summary
  {
    :Asserts => @asserts_count,
    :Tests   => @tests_count,
    :Passed  => @passed_count,
    :Failed  => @fails_count,
    :Errored => @errors_count,
    :Skipped => @skipped_count

  }.map do |key, value|
    "#{value} #{key}"
  end.join(', ')
end
testing(suite) click to toggle source
# File lib/tots/printer.rb, line 79
def testing(suite)
  @suite = suite

  @suites_count += 1
end
waiting() click to toggle source
# File lib/tots/printer.rb, line 67
def waiting
  raise "Should be implemented in a subclass"
end
watching(on) click to toggle source
# File lib/tots/printer.rb, line 117
def watching(on)
  if on
    puts "\n"
    @waiting = Thread.new { waiting }
  else
    @waiting.kill if @waiting
    puts "\n"
  end
end