spec/legacy/property_spec.rb in dm-mongo-adapter-0.2.0.pre3 vs spec/legacy/property_spec.rb in dm-mongo-adapter-0.6.0
- old
+ new
@@ -5,11 +5,11 @@
ENV['TZ'] = 'UTC'
class ::User
include DataMapper::Mongo::Resource
- property :id, ObjectID
+ property :id, ObjectId
property :date_time_field, DateTime
property :date_field, Date
property :type, Discriminator
end
end
@@ -30,21 +30,22 @@
_id = $db.collection('users').insert(:type => 'User', :date_time_field => t_now)
user = User.get(_id)
user.date_time_field.class.should be(DateTime)
- user.date_time_field.to_time.to_i.should == dt_now.to_time.to_i
+
+ Time.parse(user.date_time_field.to_s).to_i.should == Time.parse(dt_now.to_s).to_i
end
end
describe "Date" do
it "should be typecasted from a Time object" do
today = Date.today
_id = $db.collection('users').insert(:type => 'User', :date_field => Time.parse(today.to_s))
user = User.get(_id)
-
+
user.date_field.class.should be(Date)
Time.parse(user.date_field.to_s).should == Time.parse(today.to_s)
end
end
end