Class: BlockingMatcher
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(timeout = 0.1) ⇒ BlockingMatcher
constructor
A new instance of BlockingMatcher.
- #matches?(block) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(timeout = 0.1) ⇒ BlockingMatcher
Returns a new instance of BlockingMatcher.
2 3 4 |
# File 'lib/mspec/matchers/block_caller.rb', line 2 def initialize(timeout = 0.1) @timeout = timeout end |
Instance Method Details
#failure_message ⇒ Object
21 22 23 |
# File 'lib/mspec/matchers/block_caller.rb', line 21 def ['Expected the given Proc', 'to block the caller'] end |
#matches?(block) ⇒ Boolean
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mspec/matchers/block_caller.rb', line 6 def matches?(block) blocking = true thread = Thread.new do block.call blocking = false end thread.join(@timeout) thread.kill blocking end |
#negative_failure_message ⇒ Object
25 26 27 |
# File 'lib/mspec/matchers/block_caller.rb', line 25 def ['Expected the given Proc', 'to not block the caller'] end |