Sha256: db8a1b3cccb1d8bad42f69c7a53198e671d1c79780ffac05389f2b4548f3d1ef

Contents?: true

Size: 994 Bytes

Versions: 22

Compression:

Stored size: 994 Bytes

Contents

module Shoulda
  module Matchers
    module ActiveRecord
      module AssociationMatchers
        # @private
        class CounterCacheMatcher
          attr_accessor :missing_option

          def initialize(counter_cache, name)
            @counter_cache = counter_cache
            @name = name
            @missing_option = ''
          end

          def description
            "counter_cache => #{counter_cache}"
          end

          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

          protected

          attr_accessor :subject, :counter_cache, :name

          def option_verifier
            @option_verifier ||= OptionVerifier.new(subject)
          end
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
shoulda-matchers-4.4.1 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-4.4.0 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-4.3.0 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-4.2.0 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-4.1.2 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-4.1.1 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-4.1.0 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-4.0.1 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-3.1.3 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-4.0.0.rc1 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-3.1.2 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/shoulda-matchers-2.8.0/lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-3.1.1 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-3.1.0 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-3.0.1 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-3.0.0 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-3.0.0.rc1 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-2.8.0 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-2.8.0.rc2 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
shoulda-matchers-2.8.0.rc1 lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb