We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3ef172d commit f50c7e9Copy full SHA for f50c7e9
spec/concurrent/utility/timer_spec.rb
@@ -1,3 +1,5 @@
1
+require 'hitimes'
2
+
3
module Concurrent
4
5
describe '#timer' do
@@ -15,13 +17,12 @@ module Concurrent
15
17
end
16
18
19
it 'executes the block after the given number of seconds' do
- start = Time.now.to_f
20
latch = CountDownLatch.new(1)
- Concurrent::timer(0.1){ latch.count_down }
21
- latch.wait(1)
22
- diff = Time.now.to_f - start
23
- expect(diff).to be > 0.09
24
- expect(diff).to be < 0.5
+ duration = Hitimes::Interval.measure do
+ Concurrent::timer(0.1){ latch.count_down }
+ latch.wait(1)
+ end
25
+ expect(duration).to be_within(0.05).of(0.1)
26
27
28
it 'suppresses exceptions thrown by the block' do
0 commit comments