Sha256: aee2c08d3760e86c3d22f78b77c49eea236f9061880bd07ccbc99881b7fb2164
Contents?: true
Size: 1.26 KB
Versions: 5
Compression:
Stored size: 1.26 KB
Contents
module Remarkable module MongoMapper module Matchers class ValidateConfirmationOfMatcher < Remarkable::MongoMapper::Base #:nodoc: arguments :collection => :attributes, :as => :attribute optional :message collection_assertions :responds_to_confirmation?, :confirms? default_options :message => "doesn't match confirmation" protected def responds_to_confirmation? @subject.respond_to?(:"#{@attribute}_confirmation=") end def confirms? @subject.send(:"#{@attribute}_confirmation=", 'something') bad?('different') end end # Ensures that the model cannot be saved if one of the attributes is not confirmed. # # == Options # # * <tt>:message</tt> - value the test expects to find in <tt>errors.on(:attribute)</tt>. # Regexp, string or symbol. Default = "doesn't match confirmation" # # == Examples # # should_validate_confirmation_of :email, :password # # it { should validate_confirmation_of(:email, :password) } # def validate_confirmation_of(*attributes, &block) ValidateConfirmationOfMatcher.new(*attributes, &block).spec(self) end end end end
Version data entries
5 entries across 5 versions & 3 rubygems