minor: fix for to_json

This commit is contained in:
Kyle Banker 2010-07-07 17:04:45 -04:00
parent 2121d6c809
commit bb7cb79030
2 changed files with 17 additions and 1 deletions

View File

@ -140,7 +140,7 @@ module BSON
# but lacks an ObjectID type, this JSON format encodes the type using an $oid key.
#
# @return [String] the object id represented as MongoDB extended JSON.
def to_json(escaped=false)
def to_json(*a)
"{\"$oid\": \"#{to_s}\"}"
end

View File

@ -0,0 +1,16 @@
require 'test/test_helper'
require 'rubygems'
require 'json'
class JSONTest < Test::Unit::TestCase
include Mongo
include BSON
def test_object_id_as_json
id = ObjectID.new
obj = {'_id' => id}
assert_equal "{\"_id\":{\"$oid\": \"#{id.to_s}\"}}", obj.to_json
end
end