Class: Lepus::Testing::RSpecMatchers::ProcessLepusMessage
- Inherits:
-
Object
- Object
- Lepus::Testing::RSpecMatchers::ProcessLepusMessage
- Defined in:
- lib/lepus/testing/rspec_matchers.rb
Overview
RSpec matcher for testing consumer message processing
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expected_result = :ack) ⇒ ProcessLepusMessage
constructor
A new instance of ProcessLepusMessage.
- #matches?(consumer_class_or_message) ⇒ Boolean
- #with_delivery_info(delivery_info) ⇒ Object
-
#with_message(message_or_payload) ⇒ Object
Chainable methods.
- #with_metadata(metadata) ⇒ Object
Constructor Details
#initialize(expected_result = :ack) ⇒ ProcessLepusMessage
Returns a new instance of ProcessLepusMessage.
167 168 169 170 171 172 173 |
# File 'lib/lepus/testing/rspec_matchers.rb', line 167 def initialize(expected_result = :ack) @expected_result = expected_result @consumer_class = nil @message_or_payload = nil @delivery_info = nil @metadata = nil end |
Instance Method Details
#description ⇒ Object
203 204 205 |
# File 'lib/lepus/testing/rspec_matchers.rb', line 203 def description "#{@expected_result} message with #{@consumer_class}" end |
#failure_message ⇒ Object
195 196 197 |
# File 'lib/lepus/testing/rspec_matchers.rb', line 195 def "expected #{@consumer_class} to #{@expected_result} message, but got #{@actual_result}" end |
#failure_message_when_negated ⇒ Object
199 200 201 |
# File 'lib/lepus/testing/rspec_matchers.rb', line 199 def "expected #{@consumer_class} not to #{@expected_result} message, but it did" end |
#matches?(consumer_class_or_message) ⇒ Boolean
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/lepus/testing/rspec_matchers.rb', line 175 def matches?() if .is_a?(Class) && < Lepus::Consumer # Called with consumer class, expect message to be provided via with_message @consumer_class = return false unless @message_or_payload else # Called with message, expect consumer to be provided via with_consumer @message_or_payload = return false unless @consumer_class end result = Lepus::Testing.consumer_perform( @consumer_class, @message_or_payload ) @actual_result = result result == @expected_result end |
#with_delivery_info(delivery_info) ⇒ Object
213 214 215 216 |
# File 'lib/lepus/testing/rspec_matchers.rb', line 213 def with_delivery_info(delivery_info) @delivery_info = delivery_info self end |
#with_message(message_or_payload) ⇒ Object
Chainable methods
208 209 210 211 |
# File 'lib/lepus/testing/rspec_matchers.rb', line 208 def () @message_or_payload = self end |
#with_metadata(metadata) ⇒ Object
218 219 220 221 |
# File 'lib/lepus/testing/rspec_matchers.rb', line 218 def () @metadata = self end |