Skip to content

Commit 285c3cc

Browse files
committed
Minor test improvements
1 parent 85b99b5 commit 285c3cc

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

spec/concurrent/edge/promises_spec.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,21 +323,29 @@ def behaves_as_delay(delay, value)
323323
expect(callback_results).to contain_exactly([], [1], [], [4], [], [7])
324324
end
325325

326-
[:wait, :wait!, :value, :value!, :reason, :result].each do |method_with_timeout|
326+
methods_with_timeout = { wait: false,
327+
wait!: false,
328+
value: nil,
329+
value!: nil,
330+
reason: nil,
331+
result: nil }
332+
methods_with_timeout.each do |method_with_timeout, timeout_value|
327333
it "#{ method_with_timeout } supports setting timeout" do
328334
start_latch = Concurrent::CountDownLatch.new
329335
end_latch = Concurrent::CountDownLatch.new
330336

331337
future = future do
332338
start_latch.count_down
333-
end_latch.wait(1)
339+
end_latch.wait(0.2)
334340
end
335341

336-
start_latch.wait(1)
337-
future.send(method_with_timeout, 0.1)
342+
expect(start_latch.wait(0.1)).to eq true
338343
expect(future).not_to be_resolved
344+
expect(future.send(method_with_timeout, 0.01)).to eq timeout_value
345+
expect(future).not_to be_resolved
346+
339347
end_latch.count_down
340-
future.wait
348+
expect(future.value!).to eq true
341349
end
342350
end
343351

0 commit comments

Comments
 (0)