Class: RosettaQueue::Matchers::PublishAMessageTo
- Inherits:
-
Object
- Object
- RosettaQueue::Matchers::PublishAMessageTo
- Defined in:
- lib/rosetta_queue/spec_helpers/publishing_matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected_queue_name, options = nil) ⇒ PublishAMessageTo
constructor
A new instance of PublishAMessageTo.
- #matches?(lambda_to_run) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(expected_queue_name, options = nil) ⇒ PublishAMessageTo
Returns a new instance of PublishAMessageTo.
6 7 8 9 10 11 |
# File 'lib/rosetta_queue/spec_helpers/publishing_matchers.rb', line 6 def initialize(expected_queue_name, =nil) @options = || {} @how_many_messages_expected = (@options[:exactly] || 1).to_i @expected_queue_name = expected_queue_name @expected_queue = expected_queue_name.is_a?(Symbol) ? RosettaQueue::Destinations.lookup(expected_queue_name) : expected_queue_name end |
Instance Method Details
#description ⇒ Object
32 33 34 |
# File 'lib/rosetta_queue/spec_helpers/publishing_matchers.rb', line 32 def description "publish #{} to the '#{@expected_queue_name}' queue" end |
#failure_message ⇒ Object
24 25 26 |
# File 'lib/rosetta_queue/spec_helpers/publishing_matchers.rb', line 24 def "expected #{} published to the #{@expected_queue.inspect} queue but #{@number_of_messages_published} messages were" end |
#matches?(lambda_to_run) ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rosetta_queue/spec_helpers/publishing_matchers.rb', line 13 def matches?(lambda_to_run) #given RosettaQueue::Adapter.stub!(:instance).and_return(fake_adapter = RosettaQueue::Gateway::FakeAdapter.new) #when lambda_to_run.call #then @actual_queues = fake_adapter.queues @number_of_messages_published = @actual_queues.select{ |q| q == @expected_queue}.size @number_of_messages_published == @how_many_messages_expected end |
#negative_failure_message ⇒ Object
28 29 30 |
# File 'lib/rosetta_queue/spec_helpers/publishing_matchers.rb', line 28 def "expected ##{} NOT to be published to the #{@expected_queue.inspect} queue but that queue was published to #{@number_of_messages_published} times" end |