Skip to content

Commit d84d766

Browse files
committed
Fix block_caller
* First wait the Thread start, then wait until it blocks or finishes. * The bug would be to quit as soon as started is set, even if the Thread never blocked. * Fixes #39.
1 parent 940336d commit d84d766

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/mspec/matchers/block_caller.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ def matches?(block)
1010
blocking = false
1111
end
1212

13-
while !started and status = thread.status and status != "sleep"
13+
Thread.pass while !started
14+
15+
# Wait until the Thread status is "sleep" (then it's blocking)
16+
# or nil (the Thread finished execution, it did not block)
17+
while status = thread.status and status != "sleep"
1418
Thread.pass
1519
end
1620
thread.kill

0 commit comments

Comments
 (0)