Class: RailsAuditLog::Matchers::HaveAuditLogEntry
- Inherits:
-
Object
- Object
- RailsAuditLog::Matchers::HaveAuditLogEntry
- Defined in:
- lib/rails_audit_log/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(event) ⇒ HaveAuditLogEntry
constructor
A new instance of HaveAuditLogEntry.
- #matches?(record) ⇒ Boolean
- #touching(attribute) ⇒ Object
Constructor Details
#initialize(event) ⇒ HaveAuditLogEntry
Returns a new instance of HaveAuditLogEntry.
12 13 14 15 |
# File 'lib/rails_audit_log/matchers.rb', line 12 def initialize(event) @event = event @touching = nil end |
Instance Method Details
#description ⇒ Object
38 39 40 |
# File 'lib/rails_audit_log/matchers.rb', line 38 def description "have an audit log entry#{qualifier}" end |
#failure_message ⇒ Object
30 31 32 |
# File 'lib/rails_audit_log/matchers.rb', line 30 def "expected #{@record.class}##{@record.id} to have an audit log entry#{qualifier}" end |
#failure_message_when_negated ⇒ Object
34 35 36 |
# File 'lib/rails_audit_log/matchers.rb', line 34 def "expected #{@record.class}##{@record.id} not to have an audit log entry#{qualifier}" end |
#matches?(record) ⇒ Boolean
22 23 24 25 26 27 28 |
# File 'lib/rails_audit_log/matchers.rb', line 22 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) ⇒ Object
17 18 19 20 |
# File 'lib/rails_audit_log/matchers.rb', line 17 def touching(attribute) @touching = attribute self end |