Skip to content

Commit 46a93b7

Browse files
committed
Fixed brittle timer spec.
1 parent accacce commit 46a93b7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

spec/concurrent/utility/timer_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ module Concurrent
1717
end
1818

1919
it 'executes the block after the given number of seconds' do
20-
start = Time.now
21-
expected = Concurrent::AtomicFixnum.new(0)
22-
Concurrent::timer(0.5){ expected.increment }
23-
expected.value.should eq 0
24-
sleep(0.1)
25-
expected.value.should eq 0
26-
sleep(0.8)
27-
expected.value.should eq 1
20+
start = Time.now.to_f
21+
latch = CountDownLatch.new(1)
22+
Concurrent::timer(0.5){ latch.count_down }
23+
latch.count.should eq 1
24+
latch.wait(0.1)
25+
latch.count.should eq 1
26+
latch.wait(1)
27+
latch.count.should eq 0
2828
end
2929

3030
it 'suppresses exceptions thrown by the block' do

0 commit comments

Comments
 (0)