Sha256: e86794d617fe31819db8d523d7d2795eb41cf1352f96b799b4e8700defd62b5f
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 KB
Contents
require 'spec_helper' require 'helpers/property' require 'dm-core/property/legacy/date_string' describe DataMapper::Property::Legacy::DateString do include Helpers::Property before(:all) do property(DataMapper::Property::Legacy::DateString) end let(:date_string) { '2010-11-05' } let(:time) { Time.parse(date_string) } let(:date) { Date.parse(date_string) } describe "load" do it "should load Date Strings" do @property.load(date_string).should == date end it "should not load empty-strings" do @property.load('').should be_nil end it "should not load nil" do @property.load(nil).should be_nil end end describe "typecast" do it "should cast Date objects" do @property.typecast(date).should == date end it "should cast Time objects" do @property.typecast(time).should == date end it "should cast String objects" do @property.typecast(date_string).should == date end it "should not cast empty-strings" do @property.typecast('').should be_nil end it "should not cast nil" do @property.typecast(nil).should be_nil end end describe "dump" do it "should dump a Date object" do @property.dump(date).should == date_string end it "should dump a Time object" do @property.dump(time).should == date_string end it "should not dump nil" do @property.dump(nil).should be_nil end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dm-types-legacy-0.1.1 | spec/unit/data_string_spec.rb |
dm-types-legacy-0.1.0 | spec/unit/data_string_spec.rb |