mongo 0.19.3 → 0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. data/README.rdoc +7 -3
  2. data/Rakefile +16 -6
  3. data/bin/bson_benchmark.rb +2 -2
  4. data/examples/gridfs.rb +3 -2
  5. data/lib/mongo.rb +3 -26
  6. data/lib/mongo/collection.rb +69 -50
  7. data/lib/mongo/connection.rb +16 -41
  8. data/lib/mongo/cursor.rb +22 -32
  9. data/lib/mongo/db.rb +13 -5
  10. data/lib/mongo/exceptions.rb +11 -15
  11. data/lib/mongo/gridfs/grid.rb +14 -3
  12. data/lib/mongo/gridfs/grid_file_system.rb +28 -5
  13. data/lib/mongo/gridfs/grid_io.rb +42 -24
  14. data/lib/mongo/util/support.rb +13 -2
  15. data/mongo-ruby-driver.gemspec +3 -1
  16. data/test/collection_test.rb +62 -9
  17. data/test/connection_test.rb +21 -32
  18. data/test/conversions_test.rb +1 -1
  19. data/test/cursor_test.rb +2 -2
  20. data/test/db_api_test.rb +28 -27
  21. data/test/db_connection_test.rb +1 -1
  22. data/test/db_test.rb +23 -13
  23. data/test/grid_file_system_test.rb +30 -4
  24. data/test/grid_io_test.rb +14 -1
  25. data/test/grid_test.rb +59 -3
  26. data/test/test_helper.rb +4 -1
  27. data/test/threading/test_threading_large_pool.rb +1 -1
  28. data/test/threading_test.rb +1 -1
  29. data/test/unit/collection_test.rb +2 -2
  30. data/test/unit/cursor_test.rb +7 -0
  31. data/test/unit/db_test.rb +8 -8
  32. metadata +6 -46
  33. data/bin/gr.rb +0 -14
  34. data/lib/bson.rb +0 -46
  35. data/lib/bson/bson_c.rb +0 -20
  36. data/lib/bson/bson_ruby.rb +0 -601
  37. data/lib/bson/byte_buffer.rb +0 -224
  38. data/lib/bson/exceptions.rb +0 -39
  39. data/lib/bson/ordered_hash.rb +0 -140
  40. data/lib/bson/types/binary.rb +0 -54
  41. data/lib/bson/types/code.rb +0 -36
  42. data/lib/bson/types/dbref.rb +0 -40
  43. data/lib/bson/types/min_max_keys.rb +0 -58
  44. data/lib/bson/types/objectid.rb +0 -180
  45. data/lib/bson/types/regexp_of_holding.rb +0 -45
  46. data/lib/mongo/gridfs.rb +0 -29
  47. data/lib/mongo/gridfs/chunk.rb +0 -91
  48. data/lib/mongo/gridfs/grid_store.rb +0 -580
  49. data/lib/mongo/types/binary.rb +0 -52
  50. data/lib/mongo/types/code.rb +0 -36
  51. data/lib/mongo/types/dbref.rb +0 -40
  52. data/lib/mongo/types/min_max_keys.rb +0 -58
  53. data/lib/mongo/types/objectid.rb +0 -180
  54. data/lib/mongo/types/regexp_of_holding.rb +0 -45
  55. data/lib/mongo/util/bson_c.rb +0 -18
  56. data/lib/mongo/util/bson_ruby.rb +0 -606
  57. data/lib/mongo/util/byte_buffer.rb +0 -222
  58. data/lib/mongo/util/ordered_hash.rb +0 -140
  59. data/test/binary_test.rb +0 -15
  60. data/test/bson_test.rb +0 -459
  61. data/test/byte_buffer_test.rb +0 -81
  62. data/test/chunk_test.rb +0 -82
  63. data/test/grid_store_test.rb +0 -337
  64. data/test/objectid_test.rb +0 -125
  65. data/test/ordered_hash_test.rb +0 -172
@@ -18,6 +18,7 @@ require 'digest/md5'
18
18
 
19
19
  module Mongo
20
20
  module Support
21
+ include Mongo::Conversions
21
22
  extend self
22
23
 
23
24
  # Generate an MD5 for authentication.
@@ -49,11 +50,21 @@ module Mongo
49
50
 
50
51
  [" ", ".", "$", "/", "\\"].each do |invalid_char|
51
52
  if db_name.include? invalid_char
52
- raise InvalidName, "database names cannot contain the character '#{invalid_char}'"
53
+ raise Mongo::InvalidNSName, "database names cannot contain the character '#{invalid_char}'"
53
54
  end
54
55
  end
55
- raise InvalidName, "database name cannot be the empty string" if db_name.empty?
56
+ raise Mongo::InvalidNSName, "database name cannot be the empty string" if db_name.empty?
56
57
  db_name
57
58
  end
59
+
60
+ def format_order_clause(order)
61
+ case order
62
+ when String, Symbol then string_as_sort_parameters(order)
63
+ when Array then array_as_sort_parameters(order)
64
+ else
65
+ raise InvalidSortValueError, "Illegal sort clause, '#{order.class.name}'; must be of the form " +
66
+ "[['field1', '(ascending|descending)'], ['field2', '(ascending|descending)']]"
67
+ end
68
+ end
58
69
  end
59
70
  end
@@ -12,11 +12,13 @@ Gem::Specification.new do |s|
12
12
  s.require_paths = ['lib']
13
13
 
14
14
  s.files = ['README.rdoc', 'Rakefile', 'mongo-ruby-driver.gemspec', 'LICENSE.txt']
15
- s.files += Dir['lib/**/*.rb'] + Dir['examples/**/*.rb'] + Dir['bin/**/*.rb']
15
+ s.files += ['lib/mongo.rb'] + Dir['lib/mongo/**/*.rb']
16
+ s.files += Dir['examples/**/*.rb'] + Dir['bin/**/*.rb']
16
17
  s.test_files = Dir['test/**/*.rb']
17
18
 
18
19
  s.has_rdoc = true
19
20
  s.test_files = Dir['test/**/*.rb']
21
+ s.test_files -= Dir['test/mongo_bson/*.rb'] # remove these files from the manifest
20
22
 
21
23
  s.has_rdoc = true
22
24
  s.rdoc_options = ['--main', 'README.rdoc', '--inline-source']
@@ -2,23 +2,23 @@ require 'test/test_helper'
2
2
 
3
3
  class TestCollection < Test::Unit::TestCase
4
4
  @@connection ||= Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost', ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT)
5
- @@db = @@connection.db('ruby-mongo-test')
5
+ @@db = @@connection.db(MONGO_TEST_DB)
6
6
  @@test = @@db.collection("test")
7
7
  @@version = @@connection.server_version
8
8
 
9
9
  def setup
10
- @@test.drop()
10
+ @@test.remove
11
11
  end
12
12
 
13
13
  def test_optional_pk_factory
14
14
  @coll_default_pk = @@db.collection('stuff')
15
- assert_equal Mongo::ObjectID, @coll_default_pk.pk_factory
15
+ assert_equal BSON::ObjectID, @coll_default_pk.pk_factory
16
16
  @coll_default_pk = @@db.create_collection('more-stuff')
17
- assert_equal Mongo::ObjectID, @coll_default_pk.pk_factory
17
+ assert_equal BSON::ObjectID, @coll_default_pk.pk_factory
18
18
 
19
19
  # Create a db with a pk_factory.
20
20
  @db = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
21
- ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT).db('ruby-mongo-test', :pk => Object.new)
21
+ ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT).db(MONGO_TEST_DB, :pk => Object.new)
22
22
  @coll = @db.collection('coll-with-pk')
23
23
  assert @coll.pk_factory.is_a?(Object)
24
24
 
@@ -27,11 +27,11 @@ class TestCollection < Test::Unit::TestCase
27
27
  end
28
28
 
29
29
  def test_valid_names
30
- assert_raise InvalidName do
30
+ assert_raise Mongo::InvalidNSName do
31
31
  @@db["te$t"]
32
32
  end
33
33
 
34
- assert_raise InvalidName do
34
+ assert_raise Mongo::InvalidNSName do
35
35
  @@db['$main']
36
36
  end
37
37
 
@@ -161,6 +161,7 @@ class TestCollection < Test::Unit::TestCase
161
161
  assert_raise OperationFailure do
162
162
  @@test.update({}, {"$inc" => {"x" => 1}}, :safe => true)
163
163
  end
164
+ @@test.drop
164
165
  end
165
166
  else
166
167
  def test_safe_update
@@ -176,6 +177,7 @@ class TestCollection < Test::Unit::TestCase
176
177
  assert_raise OperationFailure do
177
178
  @@test.update({}, {"x" => 10}, :safe => true)
178
179
  end
180
+ @@test.drop
179
181
  end
180
182
  end
181
183
 
@@ -188,11 +190,12 @@ class TestCollection < Test::Unit::TestCase
188
190
  assert_raise OperationFailure do
189
191
  @@test.save({"hello" => "world"}, :safe => true)
190
192
  end
193
+ @@test.drop
191
194
  end
192
195
 
193
196
  def test_mocked_safe_remove
194
197
  @conn = Connection.new
195
- @db = @conn['mongo-ruby-test']
198
+ @db = @conn[MONGO_TEST_DB]
196
199
  @test = @db['test-safe-remove']
197
200
  @test.save({:a => 20})
198
201
  @conn.stubs(:receive).returns([[{'ok' => 0, 'err' => 'failed'}], 1, 0])
@@ -205,7 +208,7 @@ class TestCollection < Test::Unit::TestCase
205
208
 
206
209
  def test_safe_remove
207
210
  @conn = Connection.new
208
- @db = @conn['mongo-ruby-test']
211
+ @db = @conn[MONGO_TEST_DB]
209
212
  @test = @db['test-safe-remove']
210
213
  @test.save({:a => 50})
211
214
  @test.remove({}, :safe => true)
@@ -250,6 +253,25 @@ class TestCollection < Test::Unit::TestCase
250
253
  end
251
254
  end
252
255
 
256
+ def test_fields_as_hash
257
+ @@test.save(:a => 1, :b => 1, :c => 1)
258
+
259
+ doc = @@test.find_one({:a => 1}, :fields => {:b => 0})
260
+ assert_nil doc['b']
261
+ assert doc['a']
262
+ assert doc['c']
263
+
264
+ doc = @@test.find_one({:a => 1}, :fields => {:a => 1, :b => 1})
265
+ assert_nil doc['c']
266
+ assert doc['a']
267
+ assert doc['b']
268
+
269
+
270
+ assert_raise Mongo::OperationFailure do
271
+ @@test.find_one({:a => 1}, :fields => {:a => 1, :b => 0})
272
+ end
273
+ end
274
+
253
275
  def test_find_one
254
276
  id = @@test.save("hello" => "world", "foo" => "bar")
255
277
 
@@ -355,6 +377,37 @@ class TestCollection < Test::Unit::TestCase
355
377
  end
356
378
  end
357
379
 
380
+ if @@version > "1.3.0"
381
+ def test_find_and_modify
382
+ @@test << { :a => 1, :processed => false }
383
+ @@test << { :a => 2, :processed => false }
384
+ @@test << { :a => 3, :processed => false }
385
+
386
+ @@test.find_and_modify(:query => {}, :sort => [['a', -1]], :update => {"$set" => {:processed => true}})
387
+
388
+ assert @@test.find_one({:a => 3})['processed']
389
+ end
390
+
391
+ def test_find_and_modify_with_invalid_options
392
+ @@test << { :a => 1, :processed => false }
393
+ @@test << { :a => 2, :processed => false }
394
+ @@test << { :a => 3, :processed => false }
395
+
396
+ assert_raise Mongo::OperationFailure do
397
+ @@test.find_and_modify(:blimey => {})
398
+ end
399
+ end
400
+ end
401
+
402
+ if @@version >= "1.3.5"
403
+ def test_coll_stats
404
+ @@test << {:n => 1}
405
+ @@test.create_index("n")
406
+
407
+ assert_equal "#{MONGO_TEST_DB}.test", @@test.stats['ns']
408
+ end
409
+ end
410
+
358
411
  def test_saving_dates_pre_epoch
359
412
  begin
360
413
  @@test.save({'date' => Time.utc(1600)})
@@ -7,6 +7,7 @@ require 'thread'
7
7
  class TestConnection < Test::Unit::TestCase
8
8
 
9
9
  include Mongo
10
+ include BSON
10
11
 
11
12
  def setup
12
13
  @host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
@@ -15,7 +16,7 @@ class TestConnection < Test::Unit::TestCase
15
16
  end
16
17
 
17
18
  def teardown
18
- @mongo.db('ruby-mongo-test').error
19
+ @mongo.db(MONGO_TEST_DB).error
19
20
  end
20
21
 
21
22
  def test_server_info
@@ -31,25 +32,25 @@ class TestConnection < Test::Unit::TestCase
31
32
  def test_invalid_database_names
32
33
  assert_raise TypeError do @mongo.db(4) end
33
34
 
34
- assert_raise InvalidName do @mongo.db('') end
35
- assert_raise InvalidName do @mongo.db('te$t') end
36
- assert_raise InvalidName do @mongo.db('te.t') end
37
- assert_raise InvalidName do @mongo.db('te\\t') end
38
- assert_raise InvalidName do @mongo.db('te/t') end
39
- assert_raise InvalidName do @mongo.db('te st') end
35
+ assert_raise Mongo::InvalidNSName do @mongo.db('') end
36
+ assert_raise Mongo::InvalidNSName do @mongo.db('te$t') end
37
+ assert_raise Mongo::InvalidNSName do @mongo.db('te.t') end
38
+ assert_raise Mongo::InvalidNSName do @mongo.db('te\\t') end
39
+ assert_raise Mongo::InvalidNSName do @mongo.db('te/t') end
40
+ assert_raise Mongo::InvalidNSName do @mongo.db('te st') end
40
41
  end
41
42
 
42
43
  def test_database_info
43
- @mongo.drop_database('ruby-mongo-info-test')
44
- @mongo.db('ruby-mongo-info-test').collection('info-test').insert('a' => 1)
44
+ @mongo.drop_database(MONGO_TEST_DB)
45
+ @mongo.db(MONGO_TEST_DB).collection('info-test').insert('a' => 1)
45
46
 
46
47
  info = @mongo.database_info
47
48
  assert_not_nil info
48
49
  assert_kind_of Hash, info
49
- assert_not_nil info['ruby-mongo-info-test']
50
- assert info['ruby-mongo-info-test'] > 0
50
+ assert_not_nil info[MONGO_TEST_DB]
51
+ assert info[MONGO_TEST_DB] > 0
51
52
 
52
- @mongo.drop_database('ruby-mongo-info-test')
53
+ @mongo.drop_database(MONGO_TEST_DB)
53
54
  end
54
55
 
55
56
  def test_copy_database
@@ -78,21 +79,21 @@ class TestConnection < Test::Unit::TestCase
78
79
  end
79
80
 
80
81
  def test_database_names
81
- @mongo.drop_database('ruby-mongo-info-test')
82
- @mongo.db('ruby-mongo-info-test').collection('info-test').insert('a' => 1)
82
+ @mongo.drop_database(MONGO_TEST_DB)
83
+ @mongo.db(MONGO_TEST_DB).collection('info-test').insert('a' => 1)
83
84
 
84
85
  names = @mongo.database_names
85
86
  assert_not_nil names
86
87
  assert_kind_of Array, names
87
88
  assert names.length >= 1
88
- assert names.include?('ruby-mongo-info-test')
89
+ assert names.include?(MONGO_TEST_DB)
89
90
  end
90
91
 
91
92
  def test_logging
92
93
  output = StringIO.new
93
94
  logger = Logger.new(output)
94
95
  logger.level = Logger::DEBUG
95
- db = Connection.new(@host, @port, :logger => logger).db('ruby-mongo-test')
96
+ db = Connection.new(@host, @port, :logger => logger).db(MONGO_TEST_DB)
96
97
  assert output.string.include?("admin['$cmd'].find")
97
98
  end
98
99
 
@@ -120,23 +121,11 @@ class TestConnection < Test::Unit::TestCase
120
121
  end
121
122
 
122
123
  def test_nodes
123
- db = Connection.new({:left => ['foo', 123]}, nil, :connect => false)
124
- nodes = db.nodes
125
- assert_equal 2, db.nodes.length
126
- assert_equal ['foo', 123], nodes[0]
127
- assert_equal ['localhost', Connection::DEFAULT_PORT], nodes[1]
128
-
129
- db = Connection.new({:right => 'bar'}, nil, :connect => false)
130
- nodes = db.nodes
131
- assert_equal 2, nodes.length
132
- assert_equal ['localhost', Connection::DEFAULT_PORT], nodes[0]
133
- assert_equal ['bar', Connection::DEFAULT_PORT], nodes[1]
134
-
135
- db = Connection.new({:right => ['foo', 123], :left => 'bar'}, nil, :connect => false)
124
+ db = Connection.paired([['foo', 27017], ['bar', 27018]], :connect => false)
136
125
  nodes = db.nodes
137
126
  assert_equal 2, nodes.length
138
- assert_equal ['bar', Connection::DEFAULT_PORT], nodes[0]
139
- assert_equal ['foo', 123], nodes[1]
127
+ assert_equal ['foo', 27017], nodes[0]
128
+ assert_equal ['bar', 27018], nodes[1]
140
129
  end
141
130
 
142
131
  context "Saved authentications" do
@@ -174,7 +163,7 @@ class TestConnection < Test::Unit::TestCase
174
163
  context "Connection exceptions" do
175
164
  setup do
176
165
  @conn = Mongo::Connection.new('localhost', 27017, :pool_size => 10, :timeout => 10)
177
- @coll = @conn['mongo-ruby-test']['test-connection-exceptions']
166
+ @coll = @conn[MONGO_TEST_DB]['test-connection-exceptions']
178
167
  end
179
168
 
180
169
  should "release connection if an exception is raised on send_message" do
@@ -1,7 +1,7 @@
1
1
  require 'test/test_helper'
2
2
  require 'mongo/exceptions'
3
3
  require 'mongo/util/conversions'
4
- require 'mongo/util/ordered_hash'
4
+ require 'bson/ordered_hash'
5
5
 
6
6
  class ConversionsTest < Test::Unit::TestCase
7
7
  include Mongo::Conversions
@@ -8,14 +8,14 @@ class CursorTest < Test::Unit::TestCase
8
8
 
9
9
  @@connection = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
10
10
  ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT)
11
- @@db = @@connection.db('ruby-mongo-test')
11
+ @@db = @@connection.db(MONGO_TEST_DB)
12
12
  @@coll = @@db.collection('test')
13
13
  @@version = @@connection.server_version
14
14
 
15
15
  def setup
16
16
  @@coll.remove
17
17
  @@coll.insert('a' => 1) # collection not created until it's used
18
- @@coll_full_name = 'ruby-mongo-test.test'
18
+ @@coll_full_name = "#{MONGO_TEST_DB}.test"
19
19
  end
20
20
 
21
21
  def test_explain
@@ -3,10 +3,11 @@ require 'test/test_helper'
3
3
  # NOTE: assumes Mongo is running
4
4
  class DBAPITest < Test::Unit::TestCase
5
5
  include Mongo
6
+ include BSON
6
7
 
7
8
  @@conn = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
8
9
  ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT)
9
- @@db = @@conn.db("ruby-mongo-test")
10
+ @@db = @@conn.db(MONGO_TEST_DB)
10
11
  @@coll = @@db.collection('test')
11
12
  @@version = @@conn.server_version
12
13
 
@@ -14,7 +15,7 @@ class DBAPITest < Test::Unit::TestCase
14
15
  @@coll.remove
15
16
  @r1 = {'a' => 1}
16
17
  @@coll.insert(@r1) # collection not created until it's used
17
- @@coll_full_name = 'ruby-mongo-test.test'
18
+ @@coll_full_name = "#{MONGO_TEST_DB}.test"
18
19
  end
19
20
 
20
21
  def teardown
@@ -29,8 +30,8 @@ class DBAPITest < Test::Unit::TestCase
29
30
  end
30
31
 
31
32
  def test_insert
32
- assert_kind_of ObjectID, @@coll.insert('a' => 2)
33
- assert_kind_of ObjectID, @@coll.insert('b' => 3)
33
+ assert_kind_of BSON::ObjectID, @@coll.insert('a' => 2)
34
+ assert_kind_of BSON::ObjectID, @@coll.insert('b' => 3)
34
35
 
35
36
  assert_equal 3, @@coll.count
36
37
  docs = @@coll.find().to_a
@@ -62,7 +63,7 @@ class DBAPITest < Test::Unit::TestCase
62
63
  ids = @@coll.insert([{'a' => 2}, {'b' => 3}])
63
64
 
64
65
  ids.each do |i|
65
- assert_kind_of ObjectID, i
66
+ assert_kind_of BSON::ObjectID, i
66
67
  end
67
68
 
68
69
  assert_equal 3, @@coll.count
@@ -240,7 +241,7 @@ class DBAPITest < Test::Unit::TestCase
240
241
  names = @@db.collection_names
241
242
  assert names.length >= 2
242
243
  assert names.include?(@@coll.name)
243
- assert names.include?('ruby-mongo-test.test2')
244
+ assert names.include?('mongo-ruby-test.test2')
244
245
  ensure
245
246
  @@db.drop_collection('test2')
246
247
  end
@@ -413,7 +414,7 @@ class DBAPITest < Test::Unit::TestCase
413
414
  @@db.collection('does-not-exist')
414
415
  fail "expected exception"
415
416
  rescue => ex
416
- assert_equal MongoDBError, ex.class
417
+ assert_equal Mongo::MongoDBError, ex.class
417
418
  assert_equal "Collection does-not-exist doesn't exist. Currently in strict mode.", ex.to_s
418
419
  ensure
419
420
  @@db.strict = false
@@ -433,7 +434,7 @@ class DBAPITest < Test::Unit::TestCase
433
434
  end
434
435
 
435
436
  # Now the collection exists. This time we should see an exception.
436
- assert_raise MongoDBError do
437
+ assert_raise Mongo::MongoDBError do
437
438
  @@db.create_collection('foobar')
438
439
  end
439
440
  @@db.strict = false
@@ -545,7 +546,7 @@ class DBAPITest < Test::Unit::TestCase
545
546
  assert_equal 1, test.group([], {"a" => {"$gt" => 1}}, {"count" => 0}, "function (obj, prev) { prev.count++; }")[0]["count"]
546
547
 
547
548
  finalize = "function (obj) { obj.f = obj.count - 1; }"
548
- assert_equal 2, test.group([], {}, {"count" => 0}, "function (obj, prev) { prev.count++; }", true, finalize)[0]["f"]
549
+ assert_equal 2, test.group([], {}, {"count" => 0}, "function (obj, prev) { prev.count++; }", finalize)[0]["f"]
549
550
 
550
551
  test.insert("a" => 2, "b" => 3)
551
552
  expected = [{"a" => 2, "count" => 2},
@@ -646,32 +647,32 @@ class DBAPITest < Test::Unit::TestCase
646
647
  @@coll.insert({"hello" => "world"})
647
648
  @@coll.insert({"hello" => {"hello" => "world"}})
648
649
 
649
- assert_raise InvalidName do
650
+ assert_raise BSON::InvalidKeyName do
650
651
  @@coll.insert({"$hello" => "world"})
651
652
  end
652
- assert_raise InvalidName do
653
+ assert_raise BSON::InvalidKeyName do
653
654
  @@coll.insert({"hello" => {"$hello" => "world"}})
654
655
  end
655
656
 
656
657
  @@coll.insert({"he$llo" => "world"})
657
658
  @@coll.insert({"hello" => {"hell$o" => "world"}})
658
659
 
659
- assert_raise InvalidName do
660
+ assert_raise BSON::InvalidKeyName do
660
661
  @@coll.insert({".hello" => "world"})
661
662
  end
662
- assert_raise InvalidName do
663
+ assert_raise BSON::InvalidKeyName do
663
664
  @@coll.insert({"hello" => {".hello" => "world"}})
664
665
  end
665
- assert_raise InvalidName do
666
+ assert_raise BSON::InvalidKeyName do
666
667
  @@coll.insert({"hello." => "world"})
667
668
  end
668
- assert_raise InvalidName do
669
+ assert_raise BSON::InvalidKeyName do
669
670
  @@coll.insert({"hello" => {"hello." => "world"}})
670
671
  end
671
- assert_raise InvalidName do
672
+ assert_raise BSON::InvalidKeyName do
672
673
  @@coll.insert({"hel.lo" => "world"})
673
674
  end
674
- assert_raise InvalidName do
675
+ assert_raise BSON::InvalidKeyName do
675
676
  @@coll.insert({"hello" => {"hel.lo" => "world"}})
676
677
  end
677
678
  end
@@ -680,19 +681,19 @@ class DBAPITest < Test::Unit::TestCase
680
681
  assert_raise TypeError do
681
682
  @@db.collection(5)
682
683
  end
683
- assert_raise InvalidName do
684
+ assert_raise Mongo::InvalidNSName do
684
685
  @@db.collection("")
685
686
  end
686
- assert_raise InvalidName do
687
+ assert_raise Mongo::InvalidNSName do
687
688
  @@db.collection("te$t")
688
689
  end
689
- assert_raise InvalidName do
690
+ assert_raise Mongo::InvalidNSName do
690
691
  @@db.collection(".test")
691
692
  end
692
- assert_raise InvalidName do
693
+ assert_raise Mongo::InvalidNSName do
693
694
  @@db.collection("test.")
694
695
  end
695
- assert_raise InvalidName do
696
+ assert_raise Mongo::InvalidNSName do
696
697
  @@db.collection("tes..t")
697
698
  end
698
699
  end
@@ -706,19 +707,19 @@ class DBAPITest < Test::Unit::TestCase
706
707
  assert_raise TypeError do
707
708
  a.rename(5)
708
709
  end
709
- assert_raise InvalidName do
710
+ assert_raise Mongo::InvalidNSName do
710
711
  a.rename("")
711
712
  end
712
- assert_raise InvalidName do
713
+ assert_raise Mongo::InvalidNSName do
713
714
  a.rename("te$t")
714
715
  end
715
- assert_raise InvalidName do
716
+ assert_raise Mongo::InvalidNSName do
716
717
  a.rename(".test")
717
718
  end
718
- assert_raise InvalidName do
719
+ assert_raise Mongo::InvalidNSName do
719
720
  a.rename("test.")
720
721
  end
721
- assert_raise InvalidName do
722
+ assert_raise Mongo::InvalidNSName do
722
723
  a.rename("tes..t")
723
724
  end
724
725