-
Notifications
You must be signed in to change notification settings - Fork 0
/
reporter.rb
59 lines (49 loc) · 1.08 KB
/
reporter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class VerboseReporter
def initialize(running_single_test:)
@running_single_test = running_single_test
@first = true
@num_failed = 0
@num_passed = 0
end
def report_success(name, output)
puts "" unless @first
@first = false
@num_passed +=1
puts name unless @running_single_test
puts output
end
def report_fail(name, expected, actual)
puts "" unless @first
@first = false
@num_failed += 1
puts "#{name} FAILED"
puts "Expected:"
puts expected
puts "--------------------"
puts "Actual:"
puts actual
end
def report_summary
return if @running_single_test
puts "--------------------"
if @num_failed == 0
puts "OK"
else
puts "#{@num_failed} of #{@num_passed + @num_failed} failed."
end
end
end
class ConciseReporter < VerboseReporter
def report_success(_name, _output)
@num_passed += 1
print "."
end
def report_summary
if @num_failed == 0
puts ""
else
puts ""
puts "#{@num_failed} of #{@num_passed + @num_failed} failed."
end
end
end