Module: Audited::RspecMatchers

Included in:
RSpec::Matchers
Defined in:
lib/audited/rspec_matchers.rb

Defined Under Namespace

Classes: AssociatedAuditMatcher, AuditMatcher

Instance Method Summary collapse

Instance Method Details

#be_auditedObject

Ensure that the model is audited.

Options:

  • associated_with - tests that the audit makes use of the associated_with option

  • only - tests that the audit makes use of the only option *Overrides except option*

  • except - tests that the audit makes use of the except option

  • requires_comment - if specified, then the audit must require comments through the audit_comment attribute

  • on - tests that the audit makes use of the on option with specified parameters

Example:

it { should be_audited }
it { should be_audited.associated_with(:user) }
it { should be_audited.only(:field_name) }
it { should be_audited.except(:password) }
it { should be_audited.requires_comment }
it { should be_audited.on(:create).associated_with(:user).except(:password) }


22
23
24
# File 'lib/audited/rspec_matchers.rb', line 22

def be_audited
  AuditMatcher.new
end

#have_associated_auditsObject

Ensure that the model has associated audits

Example:

it { should have_associated_audits }


31
32
33
# File 'lib/audited/rspec_matchers.rb', line 31

def have_associated_audits
  AssociatedAuditMatcher.new
end