Module: RailsAuditLog::TestHelpers

Defined in:
lib/rails_audit_log/test_helpers.rb

Overview

Opt-in test helper for suppressing audit writes in test setup code.

Setup

# spec/rails_helper.rb
require "rails_audit_log/test_helpers"

RSpec.configure do |config|
  config.include RailsAuditLog::TestHelpers
end

Usage

let(:post) { without_audit_log { Post.create!(title: "fixture") } }

Instance Method Summary collapse

Instance Method Details

#without_audit_log { ... } ⇒ Object

Executes the block with audit logging disabled. A prefix-free wrapper around RailsAuditLog.disable intended for use in FactoryBot factories, let blocks, and other test setup where audit noise is unwanted.

Yields:

  • executes the block without recording any audit entries

Returns:

  • (Object)

    the return value of the block



23
24
25
# File 'lib/rails_audit_log/test_helpers.rb', line 23

def without_audit_log(&block)
  RailsAuditLog.disable(&block)
end