Use OrderedHash for sorts.

This commit is contained in:
Jim Menard 2008-12-09 07:45:48 -05:00
parent 241361285c
commit 294fa97454
1 changed files with 6 additions and 2 deletions

View File

@ -107,12 +107,16 @@ class DBAPITest < Test::Unit::TestCase
@coll.insert('b' => 3)
# Sorting (ascending)
docs = @coll.find({'a' => { '$lt' => 10 }}, :sort => { 'a' => 1 }).map
order_by = OrderedHash.new
order_by['a'] = 1
docs = @coll.find({'a' => { '$lt' => 10 }}, :sort => order_by).map
assert_equal 2, docs.size
assert_equal 1, docs.first['a']
# Sorting (descending)
docs = @coll.find({'a' => { '$lt' => 10 }}, :sort => { 'a' => -1 }).map
order_by = OrderedHash.new
order_by['a'] = -1
docs = @coll.find({'a' => { '$lt' => 10 }}, :sort => order_by).map
assert_equal 2, docs.size
assert_equal 2, docs.first['a']
end