jmongo 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/Gemfile +8 -0
  2. data/Gemfile.lock +43 -0
  3. data/Rakefile +72 -0
  4. data/jmongo.gemspec +84 -6
  5. data/lib/jmongo.rb +6 -14
  6. data/lib/jmongo/collection.rb +196 -114
  7. data/lib/jmongo/connection.rb +39 -13
  8. data/lib/jmongo/cursor.rb +161 -63
  9. data/lib/jmongo/db.rb +119 -30
  10. data/lib/jmongo/exceptions.rb +39 -0
  11. data/lib/jmongo/mongo-2.6.5.gb1.jar +0 -0
  12. data/lib/jmongo/mongo/bson.rb +130 -0
  13. data/lib/jmongo/mongo/collection.rb +185 -0
  14. data/lib/jmongo/mongo/connection.rb +45 -0
  15. data/lib/jmongo/mongo/db.rb +31 -0
  16. data/lib/jmongo/mongo/jmongo.rb +44 -0
  17. data/lib/jmongo/mongo/mongo.rb +98 -0
  18. data/lib/jmongo/mongo/ruby_ext.rb +38 -0
  19. data/lib/jmongo/mongo/utils.rb +136 -0
  20. data/lib/jmongo/version.rb +1 -1
  21. data/test-results.txt +98 -0
  22. data/test/auxillary/1.4_features.rb +166 -0
  23. data/test/auxillary/authentication_test.rb +68 -0
  24. data/test/auxillary/autoreconnect_test.rb +41 -0
  25. data/test/auxillary/fork_test.rb +30 -0
  26. data/test/auxillary/repl_set_auth_test.rb +58 -0
  27. data/test/auxillary/slave_connection_test.rb +36 -0
  28. data/test/auxillary/threaded_authentication_test.rb +101 -0
  29. data/test/bson/binary_test.rb +15 -0
  30. data/test/bson/bson_test.rb +657 -0
  31. data/test/bson/byte_buffer_test.rb +208 -0
  32. data/test/bson/hash_with_indifferent_access_test.rb +38 -0
  33. data/test/bson/json_test.rb +17 -0
  34. data/test/bson/object_id_test.rb +138 -0
  35. data/test/bson/ordered_hash_test.rb +245 -0
  36. data/test/bson/test_helper.rb +46 -0
  37. data/test/bson/timestamp_test.rb +46 -0
  38. data/test/collection_test.rb +933 -0
  39. data/test/connection_test.rb +325 -0
  40. data/test/conversions_test.rb +121 -0
  41. data/test/cursor_fail_test.rb +75 -0
  42. data/test/cursor_message_test.rb +43 -0
  43. data/test/cursor_test.rb +547 -0
  44. data/test/data/empty_data +0 -0
  45. data/test/data/sample_data +0 -0
  46. data/test/data/sample_file.pdf +0 -0
  47. data/test/data/small_data.txt +1 -0
  48. data/test/db_api_test.rb +739 -0
  49. data/test/db_connection_test.rb +15 -0
  50. data/test/db_test.rb +325 -0
  51. data/test/grid_file_system_test.rb +260 -0
  52. data/test/grid_io_test.rb +210 -0
  53. data/test/grid_test.rb +259 -0
  54. data/test/load/thin/config.ru +6 -0
  55. data/test/load/thin/config.yml.template +6 -0
  56. data/test/load/thin/load.rb +24 -0
  57. data/test/load/unicorn/config.ru +6 -0
  58. data/test/load/unicorn/load.rb +23 -0
  59. data/test/load/unicorn/unicorn.rb.template +29 -0
  60. data/test/replica_sets/connect_test.rb +111 -0
  61. data/test/replica_sets/connection_string_test.rb +29 -0
  62. data/test/replica_sets/count_test.rb +36 -0
  63. data/test/replica_sets/insert_test.rb +54 -0
  64. data/test/replica_sets/pooled_insert_test.rb +58 -0
  65. data/test/replica_sets/query_secondaries.rb +109 -0
  66. data/test/replica_sets/query_test.rb +52 -0
  67. data/test/replica_sets/read_preference_test.rb +43 -0
  68. data/test/replica_sets/refresh_test.rb +123 -0
  69. data/test/replica_sets/replication_ack_test.rb +71 -0
  70. data/test/replica_sets/rs_test_helper.rb +27 -0
  71. data/test/safe_test.rb +68 -0
  72. data/test/support/hash_with_indifferent_access.rb +186 -0
  73. data/test/support/keys.rb +45 -0
  74. data/test/support_test.rb +19 -0
  75. data/test/test_helper.rb +111 -0
  76. data/test/threading/threading_with_large_pool_test.rb +90 -0
  77. data/test/threading_test.rb +88 -0
  78. data/test/tools/auth_repl_set_manager.rb +14 -0
  79. data/test/tools/keyfile.txt +1 -0
  80. data/test/tools/repl_set_manager.rb +377 -0
  81. data/test/unit/collection_test.rb +128 -0
  82. data/test/unit/connection_test.rb +85 -0
  83. data/test/unit/cursor_test.rb +127 -0
  84. data/test/unit/db_test.rb +96 -0
  85. data/test/unit/grid_test.rb +51 -0
  86. data/test/unit/node_test.rb +73 -0
  87. data/test/unit/pool_manager_test.rb +47 -0
  88. data/test/unit/pool_test.rb +9 -0
  89. data/test/unit/read_test.rb +101 -0
  90. data/test/unit/safe_test.rb +125 -0
  91. data/test/uri_test.rb +92 -0
  92. metadata +170 -99
  93. data/lib/jmongo/ajrb.rb +0 -189
  94. data/lib/jmongo/jmongo_jext.rb +0 -302
  95. data/lib/jmongo/mongo-2.6.3.jar +0 -0
  96. data/lib/jmongo/utils.rb +0 -61
@@ -0,0 +1,128 @@
1
+ require './test/test_helper'
2
+
3
+ class CollectionTest < Test::Unit::TestCase
4
+
5
+ context "Basic operations: " do
6
+ setup do
7
+ @logger = mock()
8
+ @logger.expects(:debug)
9
+ end
10
+
11
+ should "send update message" do
12
+ @conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
13
+ @db = @conn['testing']
14
+ @coll = @db.collection('books')
15
+ @conn.expects(:send_message).with do |op, msg, log|
16
+ op == 2001
17
+ end
18
+ @coll.stubs(:log_operation)
19
+ @coll.update({}, {:title => 'Moby Dick'})
20
+ end
21
+
22
+ should "send insert message" do
23
+ @conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
24
+ @db = @conn['testing']
25
+ @coll = @db.collection('books')
26
+ @conn.expects(:send_message).with do |op, msg, log|
27
+ op == 2002
28
+ end
29
+ @coll.expects(:log_operation).with do |name, payload|
30
+ (name == :insert) && payload[:documents][0][:title].include?('Moby')
31
+ end
32
+ @coll.insert({:title => 'Moby Dick'})
33
+ end
34
+
35
+ should "send sort data" do
36
+ @conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
37
+ @db = @conn['testing']
38
+ @coll = @db.collection('books')
39
+ @conn.expects(:receive_message).with do |op, msg, log, sock|
40
+ op == 2004
41
+ end.returns([[], 0, 0])
42
+ @logger.expects(:debug)
43
+ @coll.find({:title => 'Moby Dick'}).sort([['title', 1], ['author', 1]]).next_document
44
+ end
45
+
46
+ should "not log binary data" do
47
+ @conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
48
+ @db = @conn['testing']
49
+ @coll = @db.collection('books')
50
+ data = BSON::Binary.new(("BINARY " * 1000).unpack("c*"))
51
+ @conn.expects(:send_message).with do |op, msg, log|
52
+ op == 2002
53
+ end
54
+ @coll.expects(:log_operation).with do |name, payload|
55
+ (name == :insert) && payload[:documents][0][:data].inspect.include?('Binary')
56
+ end
57
+ @coll.insert({:data => data})
58
+ end
59
+
60
+ should "send safe update message" do
61
+ @conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
62
+ @db = @conn['testing']
63
+ @coll = @db.collection('books')
64
+ @conn.expects(:send_message_with_safe_check).with do |op, msg, db_name, log|
65
+ op == 2001
66
+ end
67
+ @coll.expects(:log_operation).with do |name, payload|
68
+ (name == :update) && payload[:document][:title].include?('Moby')
69
+ end
70
+ @coll.update({}, {:title => 'Moby Dick'}, :safe => true)
71
+ end
72
+
73
+ should "send safe insert message" do
74
+ @conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
75
+ @db = @conn['testing']
76
+ @coll = @db.collection('books')
77
+ @conn.expects(:send_message_with_safe_check).with do |op, msg, db_name, log|
78
+ op == 2001
79
+ end
80
+ @coll.stubs(:log_operation)
81
+ @coll.update({}, {:title => 'Moby Dick'}, :safe => true)
82
+ end
83
+
84
+ should "not call insert for each ensure_index call" do
85
+ @conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
86
+ @db = @conn['testing']
87
+ @coll = @db.collection('books')
88
+ @coll.expects(:generate_indexes).once
89
+
90
+ @coll.ensure_index [["x", Mongo::DESCENDING]]
91
+ @coll.ensure_index [["x", Mongo::DESCENDING]]
92
+ end
93
+
94
+ should "call generate_indexes for a new direction on the same field for ensure_index" do
95
+ @conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
96
+ @db = @conn['testing']
97
+ @coll = @db.collection('books')
98
+ @coll.expects(:generate_indexes).twice
99
+
100
+ @coll.ensure_index [["x", Mongo::DESCENDING]]
101
+ @coll.ensure_index [["x", Mongo::ASCENDING]]
102
+
103
+ end
104
+
105
+ should "call generate_indexes twice because the cache time is 0 seconds" do
106
+ @conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
107
+ @db = @conn['testing']
108
+ @db.cache_time = 0
109
+ @coll = @db.collection('books')
110
+ @coll.expects(:generate_indexes).twice
111
+
112
+ @coll.ensure_index [["x", Mongo::DESCENDING]]
113
+ @coll.ensure_index [["x", Mongo::DESCENDING]]
114
+ end
115
+
116
+ should "call generate_indexes for each key when calling ensure_indexes" do
117
+ @conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
118
+ @db = @conn['testing']
119
+ @db.cache_time = 300
120
+ @coll = @db.collection('books')
121
+ @coll.expects(:generate_indexes).once.with do |a, b, c|
122
+ a == {"x"=>-1, "y"=>-1}
123
+ end
124
+
125
+ @coll.ensure_index [["x", Mongo::DESCENDING], ["y", Mongo::DESCENDING]]
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,85 @@
1
+ require './test/test_helper'
2
+ include Mongo
3
+
4
+ class ConnectionTest < Test::Unit::TestCase
5
+ context "Initialization: " do
6
+ context "given a single node" do
7
+ setup do
8
+ @conn = Connection.new('localhost', 27017, :connect => false)
9
+ TCPSocket.stubs(:new).returns(new_mock_socket)
10
+
11
+ admin_db = new_mock_db
12
+ admin_db.expects(:command).returns({'ok' => 1, 'ismaster' => 1})
13
+ @conn.expects(:[]).with('admin').returns(admin_db)
14
+ @conn.connect
15
+ end
16
+
17
+ should "set localhost and port to master" do
18
+ assert_equal 'localhost', @conn.primary_pool.host
19
+ assert_equal 27017, @conn.primary_pool.port
20
+ end
21
+
22
+ should "set connection pool to 1" do
23
+ assert_equal 1, @conn.primary_pool.size
24
+ end
25
+
26
+ should "default slave_ok to false" do
27
+ assert !@conn.slave_ok?
28
+ end
29
+ end
30
+
31
+ context "initializing with a mongodb uri" do
32
+ should "parse a simple uri" do
33
+ @conn = Connection.from_uri("mongodb://localhost", :connect => false)
34
+ assert_equal ['localhost', 27017], @conn.host_to_try
35
+ end
36
+
37
+ should "allow a complex host names" do
38
+ host_name = "foo.bar-12345.org"
39
+ @conn = Connection.from_uri("mongodb://#{host_name}", :connect => false)
40
+ assert_equal [host_name, 27017], @conn.host_to_try
41
+ end
42
+
43
+ should "parse a uri with a hyphen & underscore in the username or password" do
44
+ @conn = Connection.from_uri("mongodb://hyphen-user_name:p-s_s@localhost:27017/db", :connect => false)
45
+ assert_equal ['localhost', 27017], @conn.host_to_try
46
+ auth_hash = { 'db_name' => 'db', 'username' => 'hyphen-user_name', "password" => 'p-s_s' }
47
+ assert_equal auth_hash, @conn.auths[0]
48
+ end
49
+
50
+ should "attempt to connect" do
51
+ TCPSocket.stubs(:new).returns(new_mock_socket)
52
+ @conn = Connection.from_uri("mongodb://localhost", :connect => false)
53
+
54
+ admin_db = new_mock_db
55
+ admin_db.expects(:command).returns({'ok' => 1, 'ismaster' => 1})
56
+ @conn.expects(:[]).with('admin').returns(admin_db)
57
+ @conn.connect
58
+ end
59
+
60
+ should "raise an error on invalid uris" do
61
+ assert_raise MongoArgumentError do
62
+ Connection.from_uri("mongo://localhost", :connect => false)
63
+ end
64
+
65
+ assert_raise MongoArgumentError do
66
+ Connection.from_uri("mongodb://localhost:abc", :connect => false)
67
+ end
68
+
69
+ assert_raise MongoArgumentError do
70
+ Connection.from_uri("mongodb://localhost:27017, my.db.com:27018, ", :connect => false)
71
+ end
72
+ end
73
+
74
+ should "require all of username, password, and database if any one is specified" do
75
+ assert_raise MongoArgumentError do
76
+ Connection.from_uri("mongodb://localhost/db", :connect => false)
77
+ end
78
+
79
+ assert_raise MongoArgumentError do
80
+ Connection.from_uri("mongodb://kyle:password@localhost", :connect => false)
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,127 @@
1
+ require './test/test_helper'
2
+
3
+ class CursorTest < Test::Unit::TestCase
4
+ context "Cursor options" do
5
+ setup do
6
+ @logger = mock()
7
+ @logger.stubs(:debug)
8
+ @connection = stub(:class => Connection, :logger => @logger, :slave_ok? => false, :read_preference => :primary)
9
+ @db = stub(:name => "testing", :slave_ok? => false, :connection => @connection, :read_preference => :primary)
10
+ @collection = stub(:db => @db, :name => "items", :read_preference => :primary)
11
+ @cursor = Cursor.new(@collection)
12
+ end
13
+
14
+ should "set timeout" do
15
+ assert @cursor.timeout
16
+ assert @cursor.query_options_hash[:timeout]
17
+ end
18
+
19
+ should "set selector" do
20
+ assert_equal({}, @cursor.selector)
21
+
22
+ @cursor = Cursor.new(@collection, :selector => {:name => "Jones"})
23
+ assert_equal({:name => "Jones"}, @cursor.selector)
24
+ assert_equal({:name => "Jones"}, @cursor.query_options_hash[:selector])
25
+ end
26
+
27
+ should "set fields" do
28
+ assert_nil @cursor.fields
29
+
30
+ @cursor = Cursor.new(@collection, :fields => [:name, :date])
31
+ assert_equal({:name => 1, :date => 1}, @cursor.fields)
32
+ assert_equal({:name => 1, :date => 1}, @cursor.query_options_hash[:fields])
33
+ end
34
+
35
+ should "set mix fields 0 and 1" do
36
+ assert_nil @cursor.fields
37
+
38
+ @cursor = Cursor.new(@collection, :fields => {:name => 1, :date => 0})
39
+ assert_equal({:name => 1, :date => 0}, @cursor.fields)
40
+ assert_equal({:name => 1, :date => 0}, @cursor.query_options_hash[:fields])
41
+ end
42
+
43
+ should "set limit" do
44
+ assert_equal 0, @cursor.limit
45
+
46
+ @cursor = Cursor.new(@collection, :limit => 10)
47
+ assert_equal 10, @cursor.limit
48
+ assert_equal 10, @cursor.query_options_hash[:limit]
49
+ end
50
+
51
+
52
+ should "set skip" do
53
+ assert_equal 0, @cursor.skip
54
+
55
+ @cursor = Cursor.new(@collection, :skip => 5)
56
+ assert_equal 5, @cursor.skip
57
+ assert_equal 5, @cursor.query_options_hash[:skip]
58
+ end
59
+
60
+ should "set sort order" do
61
+ assert_nil @cursor.order
62
+
63
+ @cursor = Cursor.new(@collection, :order => "last_name")
64
+ assert_equal "last_name", @cursor.order
65
+ assert_equal "last_name", @cursor.query_options_hash[:order]
66
+ end
67
+
68
+ should "set hint" do
69
+ assert_nil @cursor.hint
70
+
71
+ @cursor = Cursor.new(@collection, :hint => "name")
72
+ assert_equal "name", @cursor.hint
73
+ assert_equal "name", @cursor.query_options_hash[:hint]
74
+ end
75
+
76
+ should "cache full collection name" do
77
+ assert_equal "testing.items", @cursor.full_collection_name
78
+ end
79
+
80
+ should "raise error when batch_size is 1" do
81
+ e = assert_raise ArgumentError do
82
+ @cursor.batch_size(1)
83
+ end
84
+ assert_equal "Invalid value for batch_size 1; must be 0 or > 1.", e.message
85
+ end
86
+
87
+ should "use the limit for batch size when it's smaller than the specified batch_size" do
88
+ @cursor.limit(99)
89
+ @cursor.batch_size(100)
90
+ assert_equal 99, @cursor.batch_size
91
+ end
92
+
93
+ should "use the specified batch_size" do
94
+ @cursor.batch_size(100)
95
+ assert_equal 100, @cursor.batch_size
96
+ end
97
+ end
98
+
99
+ context "Query fields" do
100
+ setup do
101
+ @logger = mock()
102
+ @logger.stubs(:debug)
103
+ @connection = stub(:class => Connection, :logger => @logger, :slave_ok? => false)
104
+ @db = stub(:slave_ok? => true, :name => "testing", :connection => @connection)
105
+ @collection = stub(:db => @db, :name => "items", :read_preference => :primary)
106
+ end
107
+
108
+ should "when an array should return a hash with each key" do
109
+ @cursor = Cursor.new(@collection, :fields => [:name, :age])
110
+ result = @cursor.fields
111
+ assert_equal result.keys.sort{|a,b| a.to_s <=> b.to_s}, [:age, :name].sort{|a,b| a.to_s <=> b.to_s}
112
+ assert result.values.all? {|v| v == 1}
113
+ end
114
+
115
+ should "when a string, return a hash with just the key" do
116
+ @cursor = Cursor.new(@collection, :fields => "name")
117
+ result = @cursor.fields
118
+ assert_equal result.keys.sort, ["name"]
119
+ assert result.values.all? {|v| v == 1}
120
+ end
121
+
122
+ should "return nil when neither hash nor string nor symbol" do
123
+ @cursor = Cursor.new(@collection, :fields => 1234567)
124
+ assert_nil @cursor.fields
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,96 @@
1
+ require './test/test_helper'
2
+
3
+ def insert_message(db, documents)
4
+ documents = [documents] unless documents.is_a?(Array)
5
+ message = ByteBuffer.new
6
+ message.put_int(0)
7
+ Mongo::BSON_CODER.serialize_cstr(message, "#{db.name}.test")
8
+ documents.each { |doc| message.put_array(Mongo::BSON_CODER.new.serialize(doc, true).to_a) }
9
+ message = db.add_message_headers(Mongo::Constants::OP_INSERT, message)
10
+ end
11
+
12
+ class DBTest < Test::Unit::TestCase
13
+ context "DBTest: " do
14
+ context "DB commands" do
15
+ setup do
16
+ @conn = stub()
17
+ @conn.stubs(:safe)
18
+ @conn.stubs(:read_preference)
19
+ @db = DB.new("testing", @conn)
20
+ @db.stubs(:safe)
21
+ @db.stubs(:read_preference)
22
+ @collection = mock()
23
+ @db.stubs(:system_command_collection).returns(@collection)
24
+ end
25
+
26
+ should "raise an error if given a hash with more than one key" do
27
+ if RUBY_VERSION < '1.9'
28
+ assert_raise MongoArgumentError do
29
+ @db.command(:buildinfo => 1, :somekey => 1)
30
+ end
31
+ end
32
+ end
33
+
34
+ should "raise an error if the selector is omitted" do
35
+ assert_raise MongoArgumentError do
36
+ @db.command({}, :check_response => true)
37
+ end
38
+ end
39
+
40
+ should "create the proper cursor" do
41
+ @cursor = mock(:next_document => {"ok" => 1})
42
+ Cursor.expects(:new).with(@collection,
43
+ :limit => -1, :selector => {:buildinfo => 1}, :socket => nil).returns(@cursor)
44
+ command = {:buildinfo => 1}
45
+ @db.command(command, :check_response => true)
46
+ end
47
+
48
+ should "raise an error when the command fails" do
49
+ @cursor = mock(:next_document => {"ok" => 0})
50
+ Cursor.expects(:new).with(@collection,
51
+ :limit => -1, :selector => {:buildinfo => 1}, :socket => nil).returns(@cursor)
52
+ assert_raise OperationFailure do
53
+ command = {:buildinfo => 1}
54
+ @db.command(command, :check_response => true)
55
+ end
56
+ end
57
+
58
+ should "raise an error if logging out fails" do
59
+ @db.expects(:command).returns({})
60
+ @conn.expects(:pool_size).returns(1)
61
+ assert_raise Mongo::MongoDBError do
62
+ @db.logout
63
+ end
64
+ end
65
+
66
+ should "raise an error if collection creation fails" do
67
+ @db.expects(:collection_names).returns([])
68
+ @db.expects(:command).returns({'ok' => 0})
69
+ assert_raise Mongo::MongoDBError do
70
+ @db.create_collection("foo")
71
+ end
72
+ end
73
+
74
+ should "raise an error if getlasterror fails" do
75
+ @db.expects(:command).returns({})
76
+ assert_raise Mongo::MongoDBError do
77
+ @db.get_last_error
78
+ end
79
+ end
80
+
81
+ should "raise an error if drop_index fails" do
82
+ @db.expects(:command).returns({})
83
+ assert_raise Mongo::MongoDBError do
84
+ @db.drop_index("foo", "bar")
85
+ end
86
+ end
87
+
88
+ should "raise an error if set_profiling_level fails" do
89
+ @db.expects(:command).returns({})
90
+ assert_raise Mongo::MongoDBError do
91
+ @db.profiling_level = :slow_only
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,51 @@
1
+ require './test/test_helper'
2
+
3
+ class GridTest < Test::Unit::TestCase
4
+
5
+ context "GridFS: " do
6
+ setup do
7
+ @conn = stub()
8
+ @conn.stubs(:safe)
9
+ @conn.stubs(:read_preference)
10
+ @db = DB.new("testing", @conn)
11
+ @files = mock()
12
+ @chunks = mock()
13
+
14
+ @db.expects(:[]).with('fs.files').returns(@files)
15
+ @db.expects(:[]).with('fs.chunks').returns(@chunks)
16
+ @db.stubs(:safe)
17
+ @db.stubs(:read_preference)
18
+ end
19
+
20
+ context "Grid classe with standard connections" do
21
+ setup do
22
+ @conn.expects(:slave_ok?).returns(false)
23
+ end
24
+
25
+ should "create indexes for Grid" do
26
+ @chunks.expects(:create_index)
27
+ Grid.new(@db)
28
+ end
29
+
30
+ should "create indexes for GridFileSystem" do
31
+ @files.expects(:create_index)
32
+ @chunks.expects(:create_index)
33
+ GridFileSystem.new(@db)
34
+ end
35
+ end
36
+
37
+ context "Grid classes with slave connection" do
38
+ setup do
39
+ @conn.expects(:slave_ok?).returns(true)
40
+ end
41
+
42
+ should "not create indexes for Grid" do
43
+ Grid.new(@db)
44
+ end
45
+
46
+ should "not create indexes for GridFileSystem" do
47
+ GridFileSystem.new(@db)
48
+ end
49
+ end
50
+ end
51
+ end