Sha256: 23b78ba16173803e095c471f9553e00494e5b565d3d622487958216d69f077cd

Contents?: true

Size: 961 Bytes

Versions: 13

Compression:

Stored size: 961 Bytes

Contents

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

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

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

          def matches?(subject)
            self.subject = ModelReflector.new(subject, name)

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

          protected

          attr_accessor :subject, :source, :name

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
shoulda-matchers-6.4.0 lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
shoulda-matchers-6.3.1 lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
shoulda-matchers-6.3.0 lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
shoulda-matchers-6.2.0 lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
shoulda-matchers-6.1.0 lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
shoulda-matchers-6.0.0 lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
shoulda-matchers-5.3.0 lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
shoulda-matchers-5.2.0 lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
shoulda-matchers-5.1.0 lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
shoulda-matchers-5.0.0 lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
shoulda-matchers-5.0.0.rc1 lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
shoulda-matchers-4.5.1 lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
shoulda-matchers-4.5.0 lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb