Sha256: 716cb746eebdd75db47017decc34a17425cd5b86bee8be8c10c0bc38f3b65a50

Contents?: true

Size: 1.33 KB

Versions: 11

Compression:

Stored size: 1.33 KB

Contents

module Remarkable
  module ActiveRecord
    module Matchers
      class ValidateConfirmationOfMatcher < Remarkable::ActiveRecord::Base #:nodoc:
        arguments :collection => :attributes, :as => :attribute

        optional :message
        collection_assertions :responds_to_confirmation?, :confirms?

        default_options :message => :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 = <tt>I18n.translate('activerecord.errors.messages.confirmation')</tt>
      #
      # == 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

11 entries across 11 versions & 1 rubygems

Version Path
remarkable_activerecord-3.1.7 lib/remarkable_activerecord/matchers/validate_confirmation_of_matcher.rb
remarkable_activerecord-3.1.8 lib/remarkable_activerecord/matchers/validate_confirmation_of_matcher.rb
remarkable_activerecord-3.0.10 lib/remarkable_activerecord/matchers/validate_confirmation_of_matcher.rb
remarkable_activerecord-3.1.2 lib/remarkable_activerecord/matchers/validate_confirmation_of_matcher.rb
remarkable_activerecord-3.1.0 lib/remarkable_activerecord/matchers/validate_confirmation_of_matcher.rb
remarkable_activerecord-3.1.1 lib/remarkable_activerecord/matchers/validate_confirmation_of_matcher.rb
remarkable_activerecord-3.0.9 lib/remarkable_activerecord/matchers/validate_confirmation_of_matcher.rb
remarkable_activerecord-3.1.3 lib/remarkable_activerecord/matchers/validate_confirmation_of_matcher.rb
remarkable_activerecord-3.1.4 lib/remarkable_activerecord/matchers/validate_confirmation_of_matcher.rb
remarkable_activerecord-3.1.6 lib/remarkable_activerecord/matchers/validate_confirmation_of_matcher.rb
remarkable_activerecord-3.1.5 lib/remarkable_activerecord/matchers/validate_confirmation_of_matcher.rb