Class: QueryOwl::TestHelper::EventTypeMatcher
- Inherits:
-
Object
- Object
- QueryOwl::TestHelper::EventTypeMatcher
- Defined in:
- lib/query_owl/test_helper.rb
Instance Method Summary collapse
- #does_not_match?(block) ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(type) ⇒ EventTypeMatcher
constructor
A new instance of EventTypeMatcher.
- #matches?(block) ⇒ Boolean
- #supports_block_expectations? ⇒ Boolean
Constructor Details
#initialize(type) ⇒ EventTypeMatcher
Returns a new instance of EventTypeMatcher.
51 52 53 54 |
# File 'lib/query_owl/test_helper.rb', line 51 def initialize(type) @type = type @events = [] end |
Instance Method Details
#does_not_match?(block) ⇒ Boolean
61 62 63 |
# File 'lib/query_owl/test_helper.rb', line 61 def does_not_match?(block) !matches?(block) end |
#failure_message ⇒ Object
69 70 71 |
# File 'lib/query_owl/test_helper.rb', line 69 def "expected block to trigger #{label} but none were detected" end |
#failure_message_when_negated ⇒ Object
73 74 75 76 |
# File 'lib/query_owl/test_helper.rb', line 73 def n = @events.count { |e| e[:type] == @type } "expected block not to trigger #{label} but #{n} detected" end |
#matches?(block) ⇒ Boolean
56 57 58 59 |
# File 'lib/query_owl/test_helper.rb', line 56 def matches?(block) @events = QueryOwl::TestHelper.capture_events(&block) @events.any? { |e| e[:type] == @type } end |
#supports_block_expectations? ⇒ Boolean
65 66 67 |
# File 'lib/query_owl/test_helper.rb', line 65 def supports_block_expectations? true end |