Class: RailsAuditLog::Matchers::CreateAuditLogEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_audit_log/matchers.rb

Overview

RSpec matcher — asserts that a block creates a new matching entry.

Instance Method Summary collapse

Constructor Details

#initialize(event:, touching:) ⇒ CreateAuditLogEntry

Returns a new instance of CreateAuditLogEntry.



100
101
102
103
# File 'lib/rails_audit_log/matchers.rb', line 100

def initialize(event:, touching:)
  @event    = event
  @touching = touching
end

Instance Method Details

#descriptionObject

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.



138
139
140
# File 'lib/rails_audit_log/matchers.rb', line 138

def description
  "create an audit log entry#{qualifier}"
end

#failure_messageObject

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.



128
129
130
# File 'lib/rails_audit_log/matchers.rb', line 128

def failure_message
  "expected block to create an audit log entry#{qualifier}, but none was created"
end

#failure_message_when_negatedObject

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.



133
134
135
# File 'lib/rails_audit_log/matchers.rb', line 133

def failure_message_when_negated
  "expected block not to create an audit log entry#{qualifier}, but one was created"
end

#matches?(block) ⇒ 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.

Returns:

  • (Boolean)


120
121
122
123
124
125
# File 'lib/rails_audit_log/matchers.rb', line 120

def matches?(block)
  @before = matching_scope.count
  block.call
  @after = matching_scope.count
  @after > @before
end

#supports_block_expectations?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.

Returns:

  • (Boolean)


115
116
117
# File 'lib/rails_audit_log/matchers.rb', line 115

def supports_block_expectations?
  true
end

#touching(attribute) ⇒ self

Chains an attribute filter onto the matcher.

Parameters:

  • attribute (Symbol, String)

Returns:

  • (self)


109
110
111
112
# File 'lib/rails_audit_log/matchers.rb', line 109

def touching(attribute)
  @touching = attribute
  self
end