Sha256: c2daa0b075db36f2edbb1526e7a1fa660d59193f0a3f3448e730a603f5ed89d5

Contents?: true

Size: 997 Bytes

Versions: 3

Compression:

Stored size: 997 Bytes

Contents

require File.dirname(__FILE__) + "/spec_helper"

describe DataMapper::Validations::ConfirmationValidator do
  
  before(:all) do
    class Cow

      include DataMapper::CallbacksHelper
      include DataMapper::Validations::ValidationHelper
      
      attr_accessor :name, :name_confirmation, :age
    end
  end
  
  it 'should pass validation' do
    class Cow
      validations.clear!
      validates_confirmation_of :name, :context => :save
    end
    
    betsy = Cow.new
    betsy.valid?.should == true

    betsy.name = 'Betsy'
    betsy.name_confirmation = ''
    betsy.valid?(:save).should == false
    betsy.errors.full_messages.first.should == 'Name does not match the confirmation'

    betsy.name = ''
    betsy.name_confirmation = 'Betsy'
    betsy.valid?(:save).should == false
    betsy.errors.full_messages.first.should == 'Name does not match the confirmation'

    betsy.name = 'Betsy'
    betsy.name_confirmation = 'Betsy'
    betsy.valid?(:save).should == true
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
datamapper-0.2.1 spec/validates_confirmation_of_spec.rb
datamapper-0.2.2 spec/validates_confirmation_of_spec.rb
datamapper-0.2.3 spec/validates_confirmation_of_spec.rb