Sha256: a9dca848cb85b76ee6f0934d5daa1e8e208a3c095e99cb458c12aa42823254e1
Contents?: true
Size: 961 Bytes
Versions: 1
Compression:
Stored size: 961 Bytes
Contents
module Remarkable::Mongoid module Matchers # Specify the document validates the association # # examples: # it { should validate_association :dog } # # @param [Symbol] # # @return [Remarkable::Mongoid::Matchers::ValidateAssociationMatcher] def validate_association(attr) ValidateAssociationMatcher.new(attr) end class ValidateAssociationMatcher attr_accessor :attr def initialize(attr) self.attr = attr.to_sym end def matches?(subject) @subject = subject validations = @subject._validators[attr] validations.detect { |k| k.class == ::Mongoid::Validations::AssociatedValidator } end def description "validates the :#{attr} association" end def failure_message_for_should "\nAssociation validation failure\nExpected: #{@subject.class} to validate the '#{attr}' association" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
remarkable_mongoid-0.6.0 | lib/remarkable/mongoid/validate_association.rb |