Class: QueryOwl::TestHelper::EventTypeMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/query_owl/test_helper.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


61
62
63
# File 'lib/query_owl/test_helper.rb', line 61

def does_not_match?(block)
  !matches?(block)
end

#failure_messageObject



69
70
71
# File 'lib/query_owl/test_helper.rb', line 69

def failure_message
  "expected block to trigger #{label} but none were detected"
end

#failure_message_when_negatedObject



73
74
75
76
# File 'lib/query_owl/test_helper.rb', line 73

def failure_message_when_negated
  n = @events.count { |e| e[:type] == @type }
  "expected block not to trigger #{label} but #{n} detected"
end

#matches?(block) ⇒ Boolean

Returns:

  • (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

Returns:

  • (Boolean)


65
66
67
# File 'lib/query_owl/test_helper.rb', line 65

def supports_block_expectations?
  true
end