Class: RailsAuditLog::Matchers::HaveAuditLogEntry
- Inherits:
-
Object
- Object
- RailsAuditLog::Matchers::HaveAuditLogEntry
- Defined in:
- lib/rails_audit_log/matchers.rb
Overview
RSpec matcher — asserts that a record already has a matching entry.
Instance Method Summary collapse
- #description ⇒ Object private
- #failure_message ⇒ Object private
- #failure_message_when_negated ⇒ Object private
-
#initialize(event) ⇒ HaveAuditLogEntry
constructor
A new instance of HaveAuditLogEntry.
- #matches?(record) ⇒ Boolean private
-
#touching(attribute) ⇒ self
Chains an attribute filter onto the matcher.
Constructor Details
#initialize(event) ⇒ HaveAuditLogEntry
Returns a new instance of HaveAuditLogEntry.
50 51 52 53 |
# File 'lib/rails_audit_log/matchers.rb', line 50 def initialize(event) @event = event @touching = nil end |
Instance Method Details
#description ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
84 85 86 |
# File 'lib/rails_audit_log/matchers.rb', line 84 def description "have an audit log entry#{qualifier}" end |
#failure_message ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 |
# File 'lib/rails_audit_log/matchers.rb', line 74 def "expected #{@record.class}##{@record.id} to have an audit log entry#{qualifier}" end |
#failure_message_when_negated ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
79 80 81 |
# File 'lib/rails_audit_log/matchers.rb', line 79 def "expected #{@record.class}##{@record.id} not to have an audit log entry#{qualifier}" end |
#matches?(record) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 68 69 70 71 |
# File 'lib/rails_audit_log/matchers.rb', line 65 def matches?(record) @record = record scope = record.audit_log_entries scope = scope.where(event: @event.to_s) if @event scope = scope.touching(@touching) if @touching scope.exists? end |
#touching(attribute) ⇒ self
Chains an attribute filter onto the matcher.
59 60 61 62 |
# File 'lib/rails_audit_log/matchers.rb', line 59 def touching(attribute) @touching = attribute self end |