Class: MicroTest::DocFormatter
Instance Attribute Summary
#duration, #failed, #passed
Instance Method Summary
collapse
#after_class, #after_results, #before_suite, #before_test, inherited, set_short_name, short_name
Constructor Details
Returns a new instance of DocFormatter.
7
8
9
|
# File 'lib/micro_test/formatters/doc_formatter.rb', line 7
def initialize
@failures = []
end
|
Instance Method Details
#after_suite(test_classes) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/micro_test/formatters/doc_formatter.rb', line 42
def after_suite(test_classes)
print_failures(@failures) if failed > 0
puts
msg = "#{passed + failed} examples, #{failed} failures"
if failed > 0
puts red(msg)
else
puts msg
end
puts
super
end
|
#after_test(test) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/micro_test/formatters/doc_formatter.rb', line 15
def after_test(test)
super
if test.passed?
puts green(" #{test.desc}")
else
test.asserts.each do |assert|
next if assert[:value]
@failures << { :test => test, :assert => assert }
puts red(" #{test.desc}")
end
end
end
|
#before_class(test_class) ⇒ Object
11
12
13
|
# File 'lib/micro_test/formatters/doc_formatter.rb', line 11
def before_class(test_class)
puts "\n#{test_class.name}"
end
|
#print_failures(failures) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/micro_test/formatters/doc_formatter.rb', line 28
def print_failures(failures)
puts
puts "Failures:"
puts
failures.each_with_index do |failure, idx|
test = failure[:test]
assert = failure[:assert]
puts
puts " #{idx + 1}) #{test.test_class.name} #{test.desc}"
puts red(" Failure/Error: #{assert[:line].strip}")
puts cyan(" #{assert[:file_path]}:#{assert[:line_num]}")
end
end
|