Module: RailsAuditLog::Matchers
- Defined in:
- lib/rails_audit_log/matchers.rb
Overview
RSpec matchers for asserting audit log behaviour.
Setup
# spec/rails_helper.rb
require "rails_audit_log/matchers"
RSpec.configure do |config|
config.include RailsAuditLog::Matchers
end
Usage
# Assert a record already has an entry
expect(post).to have_audit_log_entry(:update).touching(:title)
# Assert a block creates a new entry
expect { post.update!(title: "New") }.to create_audit_log_entry(event: :update, touching: :title)
Defined Under Namespace
Classes: CreateAuditLogEntry, HaveAuditLogEntry
Instance Method Summary collapse
-
#create_audit_log_entry(event: nil, touching: nil) ⇒ CreateAuditLogEntry
Returns a matcher that asserts the block creates at least one new AuditLogEntry matching the given filters.
-
#have_audit_log_entry(event = nil) ⇒ HaveAuditLogEntry
Returns a matcher that asserts the record has at least one matching AuditLogEntry.
Instance Method Details
#create_audit_log_entry(event: nil, touching: nil) ⇒ CreateAuditLogEntry
Returns a matcher that asserts the block creates at least one new AuditLogEntry matching the given filters.
44 45 46 |
# File 'lib/rails_audit_log/matchers.rb', line 44 def create_audit_log_entry(event: nil, touching: nil) CreateAuditLogEntry.new(event: event, touching: touching) end |
#have_audit_log_entry(event = nil) ⇒ HaveAuditLogEntry
Returns a matcher that asserts the record has at least one matching AuditLogEntry.
31 32 33 |
# File 'lib/rails_audit_log/matchers.rb', line 31 def have_audit_log_entry(event = nil) HaveAuditLogEntry.new(event) end |