Sha256: 58a3734aa9dd6b92ebec2bab0a1ca0702c0ee158452b6f636dd97b0682e788cc

Contents?: true

Size: 667 Bytes

Versions: 3

Compression:

Stored size: 667 Bytes

Contents

require 'pathname'
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'

class Monica # :nodoc:
  include DataMapper::Resource
  property :id, Integer, :serial => true
  property :birth_date, Date, :auto_validation => false
  validates_is_primitive :birth_date
end

describe DataMapper::Validate::PrimitiveValidator do
  it "should validate a property to check for the type" do
    b = Monica.new
    p b.valid?
    p b.errors
    b.should be_valid

    b.birth_date = 'ABC'
    b.should_not be_valid
    b.birth_date.should eql('ABC')
    b.birth_date = '2008-01-01'
    b.should be_valid
    b.birth_date.should eql(Date.civil(2008,1,1))
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dm-validations-0.9.3 spec/integration/primitive_validator_spec.rb
dm-validations-0.9.4 spec/integration/primitive_validator_spec.rb
dm-validations-0.9.2 spec/integration/primitive_validator_spec.rb