Module: Proletariat::Testing
- Defined in:
- lib/proletariat/testing.rb,
lib/proletariat/testing/expectation.rb,
lib/proletariat/testing/expectation_guarantor.rb
Overview
Public: Mixin to aid solve test synchronization issues while still running
Proletariat the same way you would in production.
Defined Under Namespace
Classes: Expectation, ExpectationGuarantor
Instance Method Summary collapse
-
#message ⇒ Object
Public: Builds an Expectation instance which listens for a single message on any topic.
-
#wait_for(*expectations, &block) ⇒ Object
Public: Creates and runs a new ExpectationGuarantor from a given list of Expectation instances and a block.
Instance Method Details
#message ⇒ Object
Public: Builds an Expectation instance which listens for a single message
on any topic.
Returns a new Expectation instance.
13 14 15 |
# File 'lib/proletariat/testing.rb', line 13 def Proletariat::Testing::Expectation.new(['#'], 1) end |
#wait_for(*expectations, &block) ⇒ Object
Public: Creates and runs a new ExpectationGuarantor from a given list of
Expectation instances and a block.
expectations - One or more Expectation instances. block - A block within which the expectations should be
satisfied.
Examples
wait_for 3..on_topic 'email_sent'
# ... [Time passes]
# => 'nil'
wait_for .on_topic 'hell_freezes_over'
# ... [Time passes]
# => MessageTimeoutError
Returns ExpectationGuarantor.
35 36 37 38 39 40 |
# File 'lib/proletariat/testing.rb', line 35 def wait_for(*expectations, &block) guarantor = ExpectationGuarantor.new(expectations, &block) guarantor.guarantee if block.present? guarantor end |