From eca6653bc26f85062d6dd161f6286179bc7dd9d8 Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Fri, 5 Aug 2011 17:43:39 -0400 Subject: [PATCH] RUBY-281 make BSON::OrderedHash#inspect more precise. --- lib/bson/ordered_hash.rb | 4 ++-- test/bson/ordered_hash_test.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/bson/ordered_hash.rb b/lib/bson/ordered_hash.rb index c523dab..ab9a4be 100644 --- a/lib/bson/ordered_hash.rb +++ b/lib/bson/ordered_hash.rb @@ -119,9 +119,9 @@ module BSON end def inspect - str = '{' + str = "##{self.[](k).inspect}" }.join(", ") - str << '}' + str << '}>' end def delete(key, &block) diff --git a/test/bson/ordered_hash_test.rb b/test/bson/ordered_hash_test.rb index 16e05ea..0cd4a14 100644 --- a/test/bson/ordered_hash_test.rb +++ b/test/bson/ordered_hash_test.rb @@ -38,6 +38,7 @@ class OrderedHashTest < Test::Unit::TestCase same_doc = BSON::OrderedHash.new same_doc['_id'] = 'ab12' same_doc['name'] = 'test' + list << doc list << same_doc @@ -191,7 +192,7 @@ class OrderedHashTest < Test::Unit::TestCase end def test_inspect_retains_order - assert_equal '{"c"=>1, "a"=>2, "z"=>3}', @oh.inspect + assert_equal "#1, \"a\"=>2, \"z\"=>3}>", @oh.inspect end def test_clear