minor: cleaner output for cursor inspect

This commit is contained in:
Kyle Banker 2010-07-02 17:24:45 -04:00
parent a24448d911
commit 2121d6c809
2 changed files with 13 additions and 0 deletions

View File

@ -275,6 +275,12 @@ module Mongo
:timeout => @timeout }
end
# Clean output for inspect.
def inspect
"<Mongo::Cursor:0x#{object_id.to_s(16)} namespace='#{@db.name}.#{@collection.name}' " +
"@selector=#{@selector.inspect}>"
end
private
# Convert the +:fields+ parameter from a single field name or an array

View File

@ -17,6 +17,13 @@ class CursorTest < Test::Unit::TestCase
@@coll_full_name = "#{MONGO_TEST_DB}.test"
end
def test_inspect
selector = {:a => 1}
cursor = @@coll.find(selector)
assert_equal "<Mongo::Cursor:0x#{cursor.object_id.to_s(16)} namespace='#{@@db.name}.#{@@coll.name}' " +
"@selector=#{selector.inspect}>", cursor.inspect
end
def test_explain
cursor = @@coll.find('a' => 1)
explaination = cursor.explain