Sha256: 62adba3bae3e24ed4d84650f7a3d238eb465ad8c9c534ac947340f9c47813d7f
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
require 'spec_helper' require 'helpers/property' require 'dm-core/property/legacy/time_string' describe DataMapper::Property::Legacy::TimeString do include Helpers::Property before(:all) do property(DataMapper::Property::Legacy::TimeString) end let(:time_string) { '2010-11-05 00:00:00 -0700' } let(:time) { Time.parse(time_string) } let(:date) { Date.parse(time_string) } describe "load" do it "should load Time strings" do @property.load(time_string).should == time end it "should load Date strings" do @property.load(time_string).should == time 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 Time objects" do @property.typecast(time).should == time end it "should cast Date objects" do @property.typecast(date).should == time end it "should cast String objects" do @property.typecast(time_string).should == time 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 Time object" do @property.dump(time).should == time_string end it "should dump a Date object" do @property.dump(date).should == time_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/time_string_spec.rb |
dm-types-legacy-0.1.0 | spec/unit/time_string_spec.rb |