Class: Turn::DotReporter

Inherits:
Reporter show all
Defined in:
lib/turn/reporters/dot_reporter.rb

Overview

Traditional Dot Reporter

Constant Summary

Constants included from Colorize

Colorize::COLORLESS_TERMINALS

Instance Attribute Summary

Attributes inherited from Reporter

#io

Instance Method Summary collapse

Methods inherited from Reporter

#initialize

Methods included from Colorize

blue, bold, color_supported?, colorize?, #colorize?, error, fail, green, included, magenta, pass, red, skip

Constructor Details

This class inherits a constructor from Turn::Reporter

Instance Method Details

#error(exception, message = nil) ⇒ Object



29
30
31
# File 'lib/turn/reporters/dot_reporter.rb', line 29

def error(exception, message=nil)
  io.print Colorize.error('E'); io.flush
end

#fail(assertion, message = nil) ⇒ Object



25
26
27
# File 'lib/turn/reporters/dot_reporter.rb', line 25

def fail(assertion, message=nil)
  io.print Colorize.fail('F'); io.flush
end

#finish_case(kase) ⇒ Object



40
41
# File 'lib/turn/reporters/dot_reporter.rb', line 40

def finish_case(kase)
end

#finish_suite(suite) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/turn/reporters/dot_reporter.rb', line 43

def finish_suite(suite)
  io.puts("\nFinished in %.5f seconds." % [Time.now - @time])

  report = ''

  list = []
  suite.each do |testcase|
    testcase.each do |testunit|
      if testunit.fail? || testunit.error?
        list << testunit
      end
    end
  end

  unless list.empty? # or verbose?
    #report << "\n\n-- Failures and Errors --\n\n"
    list.uniq.each do |testunit|
      message = []
      message << (testunit.fail? ? FAIL : ERROR)
      message << testunit.message.tabto(2)
      message << clean_backtrace(testunit.backtrace).join("\n").tabto(2)
      report << "\n" << message.join("\n") << "\n"
    end
    report << "\n"
  end

  io.puts report

  # @TODO: Add something like suite.count(:tests, :passes) or
  #        suite.count(tests: "%d tests", passes: "%d passes")
  #        to cleanup, which will return something handy
  #        (suite.count(:test, :passes).test proxy maybe?)
  total      = "%d tests" % suite.count_tests
  passes     = "%d passed" % suite.count_passes
  assertions = "%d assertions" % suite.count_assertions
  failures   = "%s failures" % suite.count_failures
  errors     = "%s errors" % suite.count_errors
  skips      = "%s skips" % suite.count_skips

  tally = [total, passes, assertions, failures, errors, skips].join(", ")

  io.puts suite.passed? ? Colorize.green(tally) : Colorize.red(tally)
end

#finish_test(test) ⇒ Object



37
38
# File 'lib/turn/reporters/dot_reporter.rb', line 37

def finish_test(test)
end

#pass(message = nil) ⇒ Object



21
22
23
# File 'lib/turn/reporters/dot_reporter.rb', line 21

def pass(message=nil)
  io.print Colorize.pass('S'); io.flush
end

#skip(exception, message = nil) ⇒ Object



33
34
35
# File 'lib/turn/reporters/dot_reporter.rb', line 33

def skip(exception, message=nil)
  io.print Colorize.skip('-'); io.flush
end

#start_case(kase) ⇒ Object



15
16
# File 'lib/turn/reporters/dot_reporter.rb', line 15

def start_case(kase)
end

#start_suite(suite) ⇒ Object



9
10
11
12
13
# File 'lib/turn/reporters/dot_reporter.rb', line 9

def start_suite(suite)
  @time = Time.now
  io.puts "Loaded suite #{suite.name}"
  io.puts "Started"
end

#start_test(test) ⇒ Object



18
19
# File 'lib/turn/reporters/dot_reporter.rb', line 18

def start_test(test)
end