class Shoulda::Matchers::ActiveRecord::AssociationMatchers::CounterCacheMatcher

Attributes

counter_cache[RW]
missing_option[RW]
name[RW]
subject[RW]

Public Class Methods

new(counter_cache, name) click to toggle source
# File lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb, line 8
def initialize(counter_cache, name)
  @counter_cache = counter_cache
  @name = name
  @missing_option = ''
end

Public Instance Methods

description() click to toggle source
# File lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb, line 14
def description
  "counter_cache => #{counter_cache}"
end
matches?(subject) click to toggle source
# File lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb, line 18
def matches?(subject)
  self.subject = ModelReflector.new(subject, name)

  if option_verifier.correct_for_string?(:counter_cache, counter_cache)
    true
  else
    self.missing_option = "#{name} should have #{description}"
    false
  end
end

Private Instance Methods

option_verifier() click to toggle source
# File lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb, line 33
def option_verifier
  @option_verifier ||= OptionVerifier.new(subject)
end