Fix block_caller · ruby/mspec@d84d766 (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Commit d84d766

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.

File tree

1 file changed

lines changed

1 file changed

lines changed

Lines changed: 5 additions & 1 deletion

Original file line number Diff line number Diff line change
@@ -10,7 +10,11 @@ def matches?(block)
10 10 blocking = false
11 11 end
12 12
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"
14 18 Thread.pass
15 19 end
16 20 thread.kill