Class: Audited::RspecMatchers::AuditMatcher
- Inherits:
-
Object
- Object
- Audited::RspecMatchers::AuditMatcher
- Defined in:
- lib/audited/rspec_matchers.rb
Overview
:nodoc:
Instance Method Summary collapse
- #associated_with(model) ⇒ Object
- #description ⇒ Object
- #except(*fields) ⇒ Object
- #failure_message ⇒ Object
-
#initialize ⇒ AuditMatcher
constructor
A new instance of AuditMatcher.
- #matches?(subject) ⇒ Boolean
- #negative_failure_message ⇒ Object (also: #failure_message_when_negated)
- #on(*actions) ⇒ Object
- #only(*fields) ⇒ Object
- #requires_comment ⇒ Object
Constructor Details
#initialize ⇒ AuditMatcher
Returns a new instance of AuditMatcher.
36 37 38 |
# File 'lib/audited/rspec_matchers.rb', line 36 def initialize @options = {} end |
Instance Method Details
#associated_with(model) ⇒ Object
40 41 42 43 |
# File 'lib/audited/rspec_matchers.rb', line 40 def associated_with(model) @options[:associated_with] = model self end |
#description ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/audited/rspec_matchers.rb', line 80 def description description = "audited" description += " associated with #{@options[:associated_with]}" if @options.key?(:associated_with) description += " only => #{@options[:only].join ", "}" if @options.key?(:only) description += " except => #{@options[:except].join(", ")}" if @options.key?(:except) description += " requires audit_comment" if @options.key?(:comment_required) description end |
#except(*fields) ⇒ Object
50 51 52 53 |
# File 'lib/audited/rspec_matchers.rb', line 50 def except(*fields) @options[:except] = fields.flatten.map(&:to_s) self end |
#failure_message ⇒ Object
70 71 72 |
# File 'lib/audited/rspec_matchers.rb', line 70 def "Expected #{@expectation}" end |
#matches?(subject) ⇒ Boolean
65 66 67 68 |
# File 'lib/audited/rspec_matchers.rb', line 65 def matches?(subject) @subject = subject auditing_enabled? && end |
#negative_failure_message ⇒ Object Also known as: failure_message_when_negated
74 75 76 |
# File 'lib/audited/rspec_matchers.rb', line 74 def "Did not expect #{@expectation}" end |
#on(*actions) ⇒ Object
60 61 62 63 |
# File 'lib/audited/rspec_matchers.rb', line 60 def on(*actions) @options[:on] = actions.flatten.map(&:to_sym) self end |
#only(*fields) ⇒ Object
45 46 47 48 |
# File 'lib/audited/rspec_matchers.rb', line 45 def only(*fields) @options[:only] = fields.flatten.map(&:to_s) self end |
#requires_comment ⇒ Object
55 56 57 58 |
# File 'lib/audited/rspec_matchers.rb', line 55 def requires_comment @options[:comment_required] = true self end |