Sha256: a59c4296a1d236b0b144c06ace53a9c1500794ec36a5e32014684139a7c38680

Contents?: true

Size: 842 Bytes

Versions: 1

Compression:

Stored size: 842 Bytes

Contents

context 'A Cow' do
  
  setup do
    class Cow

      include DataMapper::Extensions::ValidationHelper
      
      attr_accessor :name, :name_confirmation, :age
    end
  end
  
  specify('') 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

1 entries across 1 versions & 1 rubygems

Version Path
datamapper-0.1.0 spec/validates_confirmation_of.rb