Class: DeliveryMatchers::BeDelivered
- Inherits:
-
Object
- Object
- DeliveryMatchers::BeDelivered
- Defined in:
- lib/delivery_matchers/be_delivered.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(first = {}, second = {}) ⇒ BeDelivered
constructor
A new instance of BeDelivered.
- #matches?(email) ⇒ Boolean
Constructor Details
#initialize(first = {}, second = {}) ⇒ BeDelivered
Returns a new instance of BeDelivered.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/delivery_matchers/be_delivered.rb', line 5 def initialize(first={}, second={}) case first when Time # Allow user to specify the :on date as the first argument: # be_delivered 1.day.from_now, via_queue: 'priority' = second [:on] = first when Hash = first end # Rename the hash keys used by this matcher to match the keys used by # ActionMailer::MessageDelivery#deliver_later [:wait] ||= [:in] [:wait_until] ||= [:on] [:queue] ||= [:via_queue] @options = end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
3 4 5 |
# File 'lib/delivery_matchers/be_delivered.rb', line 3 def email @email end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/delivery_matchers/be_delivered.rb', line 3 def @options end |
Instance Method Details
#failure_message ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/delivery_matchers/be_delivered.rb', line 30 def enqueued = enqueued_jobs.map(&:inspect).join("\n ") [ "expected to find this mail delivery job in queue:", " #{expected_job}", "instead found these jobs:", " #{enqueued}" ].join("\n") end |
#failure_message_when_negated ⇒ Object
41 42 43 44 45 46 |
# File 'lib/delivery_matchers/be_delivered.rb', line 41 def [ "expected NOT to find this mail delivery job in queue:", " #{expected_job}" ].join("\n") end |
#matches?(email) ⇒ Boolean
25 26 27 28 |
# File 'lib/delivery_matchers/be_delivered.rb', line 25 def matches?(email) @email = email enqueued_jobs.any? { |job| match_expected?(job) } end |