Class: JetstreamBridge::TestHelpers::Matchers::HavePublished
- Inherits:
-
Object
- Object
- JetstreamBridge::TestHelpers::Matchers::HavePublished
- Defined in:
- lib/jetstream_bridge/test_helpers/matchers.rb
Overview
Matcher implementation for have_published
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(event_type, payload_attributes) ⇒ HavePublished
constructor
A new instance of HavePublished.
- #matches?(_actual) ⇒ Boolean
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_message ⇒ Object
29 30 31 32 33 |
# File 'lib/jetstream_bridge/test_helpers/matchers.rb', line 29 def "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_negated ⇒ Object
35 36 37 38 |
# File 'lib/jetstream_bridge/test_helpers/matchers.rb', line 35 def "expected not to have published event_type: #{@event_type.inspect} " \ "with payload: #{@payload_attributes.inspect}" end |
#matches?(_actual) ⇒ 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 |