File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -61,5 +61,14 @@ def total
61
61
62
62
return total
63
63
end
64
+
65
+ # Reset the total elapsed time. If the clock is currently running, reset the start time to now.
66
+ def reset!
67
+ @total = 0
68
+
69
+ if @started
70
+ @started = Clock . now
71
+ end
72
+ end
64
73
end
65
74
end
Original file line number Diff line number Diff line change 58
58
expect ( total ) . to be >= 0.0
59
59
end
60
60
end
61
+
62
+ with "#reset!" do
63
+ it "resets the total time" do
64
+ clock . start!
65
+ sleep ( 0.0001 )
66
+ clock . stop!
67
+ expect ( clock . total ) . to be > 0.0
68
+ clock . reset!
69
+ expect ( clock . total ) . to be == 0.0
70
+ end
71
+
72
+ it "resets the start time" do
73
+ clock . start!
74
+ clock . reset!
75
+ sleep ( 0.0001 )
76
+ expect ( clock . total ) . to be > 0.0
77
+ end
78
+ end
61
79
end
You can’t perform that action at this time.
0 commit comments