represent inspected ObjectID using extended JSON format

This commit is contained in:
Kyle Banker 2010-04-13 11:30:13 -04:00
parent acc42dce65
commit cc0192b2cc
2 changed files with 3 additions and 2 deletions

View File

@ -127,7 +127,7 @@ module BSON
end
def inspect
"ObjectID('#{to_s}')"
{"$oid" => to_s}
end
# Convert to MongoDB extended JSON format. Since JSON includes type information,

View File

@ -50,7 +50,8 @@ class ObjectIDTest < Test::Unit::TestCase
end
def test_inspect
assert_equal "ObjectID('#{@o.to_s}')", @o.inspect
obj = {'$oid' => @o.to_s}
assert_equal obj, @o.inspect
end
def test_save_and_restore