Created
February 1, 2011 03:47
-
-
Save kennystone/805387 to your computer and use it in GitHub Desktop.
mongoid datetime resolution less than a second
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require "test/unit" | |
require 'mongoid' | |
class DT | |
include Mongoid::Document | |
field :birthday, :type => DateTime | |
end | |
class TestDT < Test::Unit::TestCase | |
def test_mongoid_date_time | |
t = Time.utc(2011, 1, 8, 12, 45, 55, 555000) ## 555 milliseconds | |
doc = DT.new( :birthday => t ) | |
assert_equal t.to_f, doc.birthday.to_f | |
end | |
end | |
<<HERE | |
$ ruby dt_test.rb | |
1) Failure: | |
<1294490755.555> expected but was | |
<1294490755.0>. | |
HERE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not that I know about.