Class: MicroTest::DefaultFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/micro_test/formatters/default_formatter.rb

Instance Attribute Summary

Attributes inherited from BaseFormatter

#duration, #failed, #passed

Instance Method Summary collapse

Methods inherited from BaseFormatter

#after_class, #after_results, #before_suite, #before_test, inherited, #initialize, set_short_name, short_name

Constructor Details

This class inherits a constructor from MicroTest::BaseFormatter

Instance Method Details

#after_suite(test_classes) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/micro_test/formatters/default_formatter.rb', line 26

def after_suite(test_classes)
  puts
  print_line
  print_totals
  puts " in #{yellow duration} seconds."
  print_line
  puts
  puts
end

#after_test(test) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/micro_test/formatters/default_formatter.rb', line 12

def after_test(test)
  duration = (test.duration * 10**4).round.to_f / 10**4
  color = duration < 0.01 ? :yellow : :red
  print send(color, "  #{duration.to_s.ljust(6, "0")}")

  if test.passed?
    print green(" #{test.desc}")
  else
    print_test_failure test
  end

  puts
end

#before_class(test_class) ⇒ Object



7
8
9
10
# File 'lib/micro_test/formatters/default_formatter.rb', line 7

def before_class(test_class)
  puts
  print_with_line test_class.name
end