Class: Eventifier::Matchers::Notifications
- Inherits:
-
Object
- Object
- Eventifier::Matchers::Notifications
- Defined in:
- lib/eventifier/matchers.rb
Instance Method Summary collapse
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(target) ⇒ Notifications
constructor
A new instance of Notifications.
- #matches?(block_to_test) ⇒ Boolean
Constructor Details
#initialize(target) ⇒ Notifications
Returns a new instance of Notifications.
4 5 6 |
# File 'lib/eventifier/matchers.rb', line 4 def initialize(target) @target = target end |
Instance Method Details
#failure_message_for_should ⇒ Object
19 20 21 22 |
# File 'lib/eventifier/matchers.rb', line 19 def 'should have worked' #"the block should have chronicled the '#{ @event_name }' incident for the #{ @target.class.name }##{ @target.object_id }, but it didn't" end |
#failure_message_for_should_not ⇒ Object
24 25 26 27 |
# File 'lib/eventifier/matchers.rb', line 24 def 'should not have worked' #"the block should not have chronicled the '#{ @event_name }' incident for the #{ @target.class.name }##{ @target.object_id }, but it did" end |
#matches?(block_to_test) ⇒ Boolean
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/eventifier/matchers.rb', line 8 def matches?(block_to_test) #before = incidents_count existing_notifications = @target.inject({}) do |memo, record| memo[record] = record.notifications end block_to_test.call @target.none? do |record| (existing_notifications[record] - record.notifications).empty? end end |