Class: JetstreamBridge::TestHelpers::Matchers::HavePublished

Inherits:
Object
  • Object
show all
Defined in:
lib/jetstream_bridge/test_helpers/matchers.rb

Overview

Matcher implementation for have_published

Instance Method Summary collapse

Constructor Details

#initialize(event_type, payload_attributes) ⇒ HavePublished

Returns a new instance of HavePublished.



18
19
20
21
# File 'lib/jetstream_bridge/test_helpers/matchers.rb', line 18

def initialize(event_type, payload_attributes)
  @event_type = event_type
  @payload_attributes = payload_attributes
end

Instance Method Details

#failure_messageObject



29
30
31
32
33
# File 'lib/jetstream_bridge/test_helpers/matchers.rb', line 29

def failure_message
  "expected to have published event_type: #{@event_type.inspect} " \
    "with payload: #{@payload_attributes.inspect}\n" \
    "but found events: #{TestHelpers.published_events.map { |e| e['event_type'] }.inspect}"
end

#failure_message_when_negatedObject



35
36
37
38
# File 'lib/jetstream_bridge/test_helpers/matchers.rb', line 35

def failure_message_when_negated
  "expected not to have published event_type: #{@event_type.inspect} " \
    "with payload: #{@payload_attributes.inspect}"
end

#matches?(_actual) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
# File 'lib/jetstream_bridge/test_helpers/matchers.rb', line 23

def matches?(_actual)
  TestHelpers.published_events.any? do |event|
    matches_event_type?(event) && matches_payload?(event)
  end
end