From 860ab356d226134178ebce4cfe4eb9e1c3e64c7c Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Mon, 12 Apr 2010 12:01:50 -0400 Subject: [PATCH] RUBY-121 --- lib/bson/bson_ruby.rb | 2 +- test/mongo_bson/bson_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/bson/bson_ruby.rb b/lib/bson/bson_ruby.rb index 1a3d4ef..d046f54 100644 --- a/lib/bson/bson_ruby.rb +++ b/lib/bson/bson_ruby.rb @@ -116,7 +116,7 @@ module BSON raise InvalidDocument, "Document is too large (#{@buf.size}). BSON documents are limited to 4MB (#{4 * 1024 * 1024})." end @buf.put_int(@buf.size, 0) - self + @buf end # Returns the array stored in the buffer. diff --git a/test/mongo_bson/bson_test.rb b/test/mongo_bson/bson_test.rb index 2adb3db..784fe80 100644 --- a/test/mongo_bson/bson_test.rb +++ b/test/mongo_bson/bson_test.rb @@ -22,6 +22,12 @@ class BSONTest < Test::Unit::TestCase include BSON + def test_serialize_returns_byte_buffer + doc = {'doc' => 'hello, world'} + bson = BSON.serialize(doc) + assert bson.is_a?(ByteBuffer) + end + def test_deprecated_bson_module doc = {'doc' => 'hello, world'} bson = BSON.serialize(doc)