test/unit/cursor_test.rb in mongo-1.7.1 vs test/unit/cursor_test.rb in mongo-1.8.0

- old
+ new

@@ -1,13 +1,13 @@ -require File.expand_path("../../test_helper", __FILE__) +require 'test_helper' class CursorTest < Test::Unit::TestCase context "Cursor options" do setup do @logger = mock() @logger.stubs(:debug) - @connection = stub(:class => Connection, :logger => @logger, + @connection = stub(:class => MongoClient, :logger => @logger, :slave_ok? => false, :read_preference => :primary, :log_duration => false, :tag_sets => {}, :acceptable_latency => 10) @db = stub(:name => "testing", :slave_ok? => false, :connection => @connection, :read_preference => :primary, :tag_sets => {}, :acceptable_latency => 10) @@ -76,37 +76,45 @@ @cursor = Cursor.new(@collection, :hint => "name") assert_equal "name", @cursor.hint assert_equal "name", @cursor.query_options_hash[:hint] end + should "set comment" do + assert_nil @cursor.comment + + @cursor = Cursor.new(@collection, :comment => "comment") + assert_equal "comment", @cursor.comment + assert_equal "comment", @cursor.query_options_hash[:comment] + end + should "cache full collection name" do assert_equal "testing.items", @cursor.full_collection_name end - + should "raise error when batch_size is 1" do e = assert_raise ArgumentError do @cursor.batch_size(1) end assert_equal "Invalid value for batch_size 1; must be 0 or > 1.", e.message end - + should "use the limit for batch size when it's smaller than the specified batch_size" do @cursor.limit(99) @cursor.batch_size(100) assert_equal 99, @cursor.batch_size end - + should "use the specified batch_size" do @cursor.batch_size(100) assert_equal 100, @cursor.batch_size end end context "Query fields" do setup do @logger = mock() @logger.stubs(:debug) - @connection = stub(:class => Connection, :logger => @logger, :slave_ok? => false, + @connection = stub(:class => MongoClient, :logger => @logger, :slave_ok? => false, :log_duration => false, :tag_sets =>{}, :acceptable_latency => 10) @db = stub(:slave_ok? => true, :name => "testing", :connection => @connection, :tag_sets => {}, :acceptable_latency => 10) @collection = stub(:db => @db, :name => "items", :read_preference => :primary, :tag_sets => {}, :acceptable_latency => 10)