Skip to content

Commit

Permalink
Fix block_caller
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
eregon committed Apr 4, 2018
1 parent 940336d commit d84d766
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/mspec/matchers/block_caller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ def matches?(block)
blocking = false
end

while !started and status = thread.status and status != "sleep"
Thread.pass while !started

# Wait until the Thread status is "sleep" (then it's blocking)
# or nil (the Thread finished execution, it did not block)
while status = thread.status and status != "sleep"
Thread.pass
end
thread.kill
Expand Down

0 comments on commit d84d766

Please sign in to comment.