Sha256: a1ea09a3491ae829d74d49ebe1b00fde3c769989f85b3a63b197fad24fd0ddfb
Contents?: true
Size: 1.15 KB
Versions: 4
Compression:
Stored size: 1.15 KB
Contents
require File.dirname(__FILE__) + "/spec_helper" describe DataMapper::Adapters::Sql::Coersion do before(:all) do @coersive = Class.new do include DataMapper::Adapters::Sql::Coersion end.new end it 'should cast to a BigDecimal' do target = BigDecimal.new('7.2') @coersive.type_cast_decimal('7.2').should == target @coersive.type_cast_decimal(7.2).should == target end it 'should store and load a date' do dob = Date::today bob = Person.create(:name => 'DateCoersionTest', :date_of_birth => dob) bob2 = Person[:name => 'DateCoersionTest'] bob.date_of_birth.should eql(dob) bob2.date_of_birth.should eql(dob) end it 'should cast to a Date' do target = Date.civil(2001, 1, 1) @coersive.type_cast_date('2001-1-1').should eql(target) @coersive.type_cast_date(target.dup).should eql(target) @coersive.type_cast_date(DateTime::parse('2001-1-1')).should eql(target) @coersive.type_cast_date(Time::parse('2001-1-1')).should eql(target) end it 'should cast to a String' do target = "\n\ttest\n\n\ntest\n\n" @coersive.type_cast_text(target).should == target end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
datamapper-0.2.1 | spec/coersion_spec.rb |
datamapper-0.2.2 | spec/coersion_spec.rb |
datamapper-0.2.3 | spec/coersion_spec.rb |
datamapper-0.2.4 | spec/coersion_spec.rb |