mongo_mapper 0.13.1 → 0.14.0.rc1

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 (103) hide show
  1. checksums.yaml +13 -5
  2. data/README.rdoc +3 -6
  3. data/lib/mongo_mapper.rb +1 -0
  4. data/lib/mongo_mapper/document.rb +2 -0
  5. data/lib/mongo_mapper/extensions/array.rb +14 -6
  6. data/lib/mongo_mapper/extensions/hash.rb +15 -3
  7. data/lib/mongo_mapper/extensions/object.rb +4 -0
  8. data/lib/mongo_mapper/extensions/string.rb +13 -5
  9. data/lib/mongo_mapper/plugins/accessible.rb +12 -11
  10. data/lib/mongo_mapper/plugins/associations.rb +7 -6
  11. data/lib/mongo_mapper/plugins/associations/base.rb +13 -12
  12. data/lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb +9 -8
  13. data/lib/mongo_mapper/plugins/associations/belongs_to_proxy.rb +12 -11
  14. data/lib/mongo_mapper/plugins/associations/embedded_collection.rb +4 -4
  15. data/lib/mongo_mapper/plugins/associations/in_array_proxy.rb +24 -23
  16. data/lib/mongo_mapper/plugins/associations/many_documents_as_proxy.rb +18 -16
  17. data/lib/mongo_mapper/plugins/associations/many_documents_proxy.rb +55 -48
  18. data/lib/mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb +14 -13
  19. data/lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb +7 -6
  20. data/lib/mongo_mapper/plugins/associations/many_polymorphic_proxy.rb +7 -5
  21. data/lib/mongo_mapper/plugins/associations/one_as_proxy.rb +14 -11
  22. data/lib/mongo_mapper/plugins/associations/one_embedded_polymorphic_proxy.rb +14 -13
  23. data/lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb +9 -9
  24. data/lib/mongo_mapper/plugins/associations/one_proxy.rb +27 -26
  25. data/lib/mongo_mapper/plugins/associations/proxy.rb +29 -26
  26. data/lib/mongo_mapper/plugins/callbacks.rb +13 -0
  27. data/lib/mongo_mapper/plugins/counter_cache.rb +23 -4
  28. data/lib/mongo_mapper/plugins/dirty.rb +2 -2
  29. data/lib/mongo_mapper/plugins/dynamic_querying.rb +10 -9
  30. data/lib/mongo_mapper/plugins/dynamic_querying/dynamic_finder.rb +17 -16
  31. data/lib/mongo_mapper/plugins/embedded_callbacks.rb +1 -1
  32. data/lib/mongo_mapper/plugins/identity_map.rb +1 -1
  33. data/lib/mongo_mapper/plugins/indexes.rb +1 -1
  34. data/lib/mongo_mapper/plugins/keys.rb +158 -158
  35. data/lib/mongo_mapper/plugins/keys/key.rb +16 -10
  36. data/lib/mongo_mapper/plugins/keys/static.rb +45 -0
  37. data/lib/mongo_mapper/plugins/modifiers.rb +27 -26
  38. data/lib/mongo_mapper/plugins/partial_updates.rb +86 -0
  39. data/lib/mongo_mapper/plugins/persistence.rb +7 -6
  40. data/lib/mongo_mapper/plugins/protected.rb +6 -5
  41. data/lib/mongo_mapper/plugins/querying.rb +80 -43
  42. data/lib/mongo_mapper/plugins/querying/decorated_plucky_query.rb +14 -9
  43. data/lib/mongo_mapper/plugins/scopes.rb +78 -7
  44. data/lib/mongo_mapper/plugins/timestamps.rb +1 -0
  45. data/lib/mongo_mapper/plugins/validations.rb +0 -0
  46. data/lib/mongo_mapper/version.rb +1 -1
  47. data/lib/rails/generators/mongo_mapper/config/config_generator.rb +12 -13
  48. data/lib/rails/generators/mongo_mapper/model/model_generator.rb +9 -9
  49. data/spec/functional/accessible_spec.rb +12 -12
  50. data/spec/functional/associations/belongs_to_polymorphic_proxy_spec.rb +11 -11
  51. data/spec/functional/associations/belongs_to_proxy_spec.rb +14 -15
  52. data/spec/functional/associations/in_array_proxy_spec.rb +6 -6
  53. data/spec/functional/associations/many_documents_proxy_spec.rb +89 -18
  54. data/spec/functional/associations/many_embedded_polymorphic_proxy_spec.rb +11 -11
  55. data/spec/functional/associations/many_embedded_proxy_spec.rb +1 -1
  56. data/spec/functional/associations/one_as_proxy_spec.rb +14 -14
  57. data/spec/functional/associations/one_embedded_polymorphic_proxy_spec.rb +9 -9
  58. data/spec/functional/associations/one_embedded_proxy_spec.rb +3 -3
  59. data/spec/functional/associations/one_proxy_spec.rb +14 -14
  60. data/spec/functional/caching_spec.rb +8 -8
  61. data/spec/functional/callbacks_spec.rb +87 -0
  62. data/spec/functional/counter_cache_spec.rb +89 -0
  63. data/spec/functional/dirty_spec.rb +41 -41
  64. data/spec/functional/document_spec.rb +3 -3
  65. data/spec/functional/embedded_document_spec.rb +18 -18
  66. data/spec/functional/identity_map_spec.rb +28 -15
  67. data/spec/functional/indexes_spec.rb +4 -4
  68. data/spec/functional/keys_spec.rb +12 -3
  69. data/spec/functional/logger_spec.rb +1 -1
  70. data/spec/functional/modifiers_spec.rb +2 -2
  71. data/spec/functional/partial_updates_spec.rb +577 -0
  72. data/spec/functional/protected_spec.rb +13 -13
  73. data/spec/functional/querying_spec.rb +11 -10
  74. data/spec/functional/safe_spec.rb +2 -2
  75. data/spec/functional/sci_spec.rb +3 -3
  76. data/spec/functional/scopes_spec.rb +234 -1
  77. data/spec/functional/static_keys_spec.rb +153 -0
  78. data/spec/functional/stats_spec.rb +0 -4
  79. data/spec/functional/touch_spec.rb +1 -1
  80. data/spec/functional/validations_spec.rb +59 -57
  81. data/spec/quality_spec.rb +1 -1
  82. data/spec/spec_helper.rb +7 -3
  83. data/spec/support/matchers.rb +4 -13
  84. data/spec/unit/associations/base_spec.rb +12 -12
  85. data/spec/unit/associations/belongs_to_association_spec.rb +2 -2
  86. data/spec/unit/associations/many_association_spec.rb +2 -2
  87. data/spec/unit/associations/one_association_spec.rb +2 -2
  88. data/spec/unit/associations/proxy_spec.rb +13 -15
  89. data/spec/unit/document_spec.rb +5 -5
  90. data/spec/unit/dynamic_finder_spec.rb +8 -8
  91. data/spec/unit/embedded_document_spec.rb +14 -14
  92. data/spec/unit/extensions_spec.rb +17 -17
  93. data/spec/unit/identity_map_middleware_spec.rb +5 -5
  94. data/spec/unit/key_spec.rb +24 -21
  95. data/spec/unit/keys_spec.rb +5 -5
  96. data/spec/unit/mongo_mapper_spec.rb +26 -26
  97. data/spec/unit/rails_spec.rb +2 -2
  98. data/spec/unit/serialization_spec.rb +1 -1
  99. data/spec/unit/time_zones_spec.rb +2 -2
  100. data/spec/unit/validations_spec.rb +28 -15
  101. metadata +16 -14
  102. data/lib/mongo_mapper/connections/10gen.rb +0 -0
  103. data/lib/mongo_mapper/connections/moped.rb +0 -0
@@ -0,0 +1,153 @@
1
+ require 'spec_helper'
2
+
3
+ describe MongoMapper::Plugins::Keys::Static do
4
+ before do
5
+ @klass = Class.new do
6
+ include MongoMapper::Document
7
+ end
8
+ end
9
+
10
+ it "is off by default" do
11
+ @klass.static_keys.should == false
12
+ end
13
+
14
+ it "can be turned on" do
15
+ @klass.static_keys = true
16
+ @klass.static_keys.should == true
17
+ end
18
+
19
+ describe "a class with static keys" do
20
+ before do
21
+ @klass = Class.new do
22
+ include MongoMapper::Document
23
+
24
+ self.static_keys = true
25
+
26
+ attr_accessor :an_accessor
27
+
28
+ key "valid_key", String
29
+ end
30
+
31
+ @obj = @klass.new
32
+ end
33
+
34
+ it "should be able to assign to a valid key" do
35
+ @obj.valid_key = "foo"
36
+ @obj.valid_key.should == "foo"
37
+ end
38
+
39
+ it "should raise a MissingKeyError if trying to assign to a field that does not exist" do
40
+ lambda {
41
+ @obj['foo'] = "foo"
42
+ }.should raise_error(MongoMapper::Plugins::Keys::Static::MissingKeyError)
43
+ end
44
+
45
+ it "should raise a MissingKeyError if trying to read from a field that does not exist" do
46
+ lambda {
47
+ @obj['foo']
48
+ }.should raise_error(MongoMapper::Plugins::Keys::Static::MissingKeyError)
49
+ end
50
+
51
+ it "should raise a MissingKeyError if trying to set attributes= to a field that does not exist" do
52
+ lambda {
53
+ @obj.attributes = {:foo => "foo"}
54
+ }.should raise_error(MongoMapper::Plugins::Keys::Static::MissingKeyError)
55
+ end
56
+
57
+ it "should be able to call a method" do
58
+ @obj.an_accessor = :bar
59
+ @obj.an_accessor.should == :bar
60
+ end
61
+
62
+ it "should raise a NoMethodError if trying to call the non-existant key method" do
63
+ lambda {
64
+ @obj.foo
65
+ }.should raise_error(NoMethodError)
66
+ end
67
+
68
+ it "should raise for read_key" do
69
+ lambda {
70
+ @obj.read_key('foo')
71
+ }.should raise_error(MongoMapper::Plugins::Keys::Static::MissingKeyError)
72
+ end
73
+
74
+ it "should raise for attribute" do
75
+ lambda {
76
+ @obj.attribute('foo')
77
+ }.should raise_error(MongoMapper::Plugins::Keys::Static::MissingKeyError)
78
+ end
79
+
80
+ it "should not raise if trying to assign to a field that exists (but with a symbol instead of a string)" do
81
+ lambda {
82
+ @obj.write_key(:valid_key, "foo")
83
+ }.should_not raise_error
84
+
85
+ @obj.valid_key.should == "foo"
86
+ end
87
+
88
+ it "should not raise a MissingKeyError if trying to read from a field that exists (but with a symbol instead of a string)" do
89
+ lambda {
90
+ @obj[:valid_key]
91
+ }.should_not raise_error
92
+ end
93
+
94
+ it "should not blow up when loading if there is a key defined in the db that has not been defined (but it should not load it)" do
95
+ @klass.collection.insert({ :foo => "bar", :valid_key => "something" })
96
+ @obj = @klass.first
97
+ @obj.valid_key.should == "something"
98
+
99
+ lambda {
100
+ @obj.foo
101
+ }.should raise_error(NoMethodError)
102
+ end
103
+ end
104
+
105
+ describe "a class without static keys" do
106
+ before do
107
+ @klass = Class.new do
108
+ include MongoMapper::Document
109
+ key :valid_key, String
110
+ end
111
+
112
+ @obj = @klass.new
113
+ end
114
+
115
+ it "should be able to assign to a valid key" do
116
+ @obj.valid_key = "foo"
117
+ @obj.valid_key.should == "foo"
118
+ end
119
+
120
+ it "should be able to read and assign a dynamic key" do
121
+ @obj['foo'].should be_nil
122
+ @obj['foo'] = "bar"
123
+ @obj['foo'].should == "bar"
124
+ end
125
+ end
126
+
127
+ describe "with mixed static + non static models" do
128
+ before do
129
+ @static_model = Class.new do
130
+ include MongoMapper::Document
131
+ self.static_keys = true
132
+ end
133
+
134
+ @non_static_model = Class.new do
135
+ include MongoMapper::Document
136
+ self.static_keys = false
137
+ end
138
+
139
+ @static_key_object = @static_model.new
140
+ @non_static_key_object = @non_static_model.new
141
+ end
142
+
143
+ it "should allow non-static key assignment to one, only static assignment to the other" do
144
+ @non_static_key_object['foo'] = 'bar'
145
+ @non_static_key_object.foo.should == 'bar'
146
+ @non_static_key_object['foo'].should == 'bar'
147
+
148
+ lambda {
149
+ @static_key_object['foo'] = 'bar'
150
+ }.should raise_error
151
+ end
152
+ end
153
+ end
@@ -59,10 +59,6 @@ describe "Stats" do
59
59
  expect(Docs.stats.padding_factor).to eq(Docs.collection.stats['paddingFactor'])
60
60
  end
61
61
 
62
- it "should have the correct system flags" do
63
- expect(Docs.stats.system_flags).to eq(Docs.collection.stats['systemFlags'])
64
- end
65
-
66
62
  it "should have the correct user flags" do
67
63
  expect(Docs.stats.user_flags).to eq(Docs.collection.stats['userFlags'])
68
64
  end
@@ -61,7 +61,7 @@ describe "Touch" do
61
61
 
62
62
  it 'should not be true by default' do
63
63
  @comment_class.belongs_to :post, :class => @post_class
64
- @comment_class.associations[:post].touch?.should_not be_true
64
+ @comment_class.associations[:post].touch?.should_not be_truthy
65
65
  end
66
66
 
67
67
  context 'touch the parent when true' do
@@ -57,7 +57,7 @@ describe "Validations" do
57
57
 
58
58
  it "should create a new document" do
59
59
  instance = @document.create!(:name => "James")
60
- instance.new_record?.should be_false
60
+ instance.new_record?.should be_falsey
61
61
  end
62
62
  end
63
63
 
@@ -140,7 +140,7 @@ describe "Validations" do
140
140
  validates_uniqueness_of :name, :scope => :adult
141
141
  end
142
142
  doc = document.new("name" => "joe", :adult => true)
143
- doc.save.should be_true
143
+ doc.save.should be_truthy
144
144
 
145
145
  doc2 = document.new("name" => "joe", :adult => false)
146
146
  doc2.should be_valid
@@ -149,31 +149,32 @@ describe "Validations" do
149
149
  it "should work with i18n taken message" do
150
150
  @document.create(:name => 'joe')
151
151
  doc = @document.create(:name => 'joe')
152
- doc.should have_error_on(:name, 'has already been taken')
152
+ doc.should have_error_on(:name)
153
+ doc.errors[:name].should == ['has already been taken']
153
154
  end
154
155
 
155
156
  it "should allow to update an object" do
156
157
  doc = @document.new("name" => "joe")
157
- doc.save.should be_true
158
+ doc.save.should be_truthy
158
159
 
159
- @document \
160
- .stub(:first) \
161
- .with(:name => 'joe') \
162
- .and_return(doc)
160
+ allow(@document).to \
161
+ receive(:first).
162
+ with(:name => 'joe').
163
+ and_return(doc)
163
164
 
164
165
  doc.name = "joe"
165
- doc.valid?.should be_true
166
+ doc.valid?.should be_truthy
166
167
  doc.should_not have_error_on(:name)
167
168
  end
168
169
 
169
170
  it "should fail if object name is not unique" do
170
171
  doc = @document.new("name" => "joe")
171
- doc.save.should be_true
172
+ doc.save.should be_truthy
172
173
 
173
- @document \
174
- .stub(:first) \
175
- .with(:name => 'joe') \
176
- .and_return(doc)
174
+ allow(@document).to \
175
+ receive(:first).
176
+ with(:name => 'joe').
177
+ and_return(doc)
177
178
 
178
179
  doc2 = @document.new("name" => "joe")
179
180
  doc2.should have_error_on(:name)
@@ -186,12 +187,12 @@ describe "Validations" do
186
187
  end
187
188
 
188
189
  doc = document.new("name" => "")
189
- doc.save.should be_true
190
+ doc.save.should be_truthy
190
191
 
191
- document \
192
- .stub(:first) \
193
- .with(:name => '') \
194
- .and_return(doc)
192
+ allow(@document).to \
193
+ receive(:first).
194
+ with(:name => '').
195
+ and_return(doc)
195
196
 
196
197
  doc2 = document.new("name" => "")
197
198
  doc2.should_not have_error_on(:name)
@@ -204,7 +205,7 @@ describe "Validations" do
204
205
  end
205
206
 
206
207
  doc = document.new('name' => nil)
207
- doc.save.should be_true
208
+ doc.save.should be_truthy
208
209
 
209
210
  doc2 = document.new('name' => nil)
210
211
  doc2.should_not have_error_on(:name)
@@ -217,7 +218,7 @@ describe "Validations" do
217
218
  end
218
219
 
219
220
  doc = document.new("name" => "BLAMMO")
220
- doc.save.should be_true
221
+ doc.save.should be_truthy
221
222
 
222
223
  doc2 = document.new("name" => "blammo")
223
224
  doc2.should_not have_error_on(:name)
@@ -233,7 +234,7 @@ describe "Validations" do
233
234
 
234
235
  it "should fail on entries that differ only in case" do
235
236
  doc = @document.new("name" => "BLAMMO")
236
- doc.save.should be_true
237
+ doc.save.should be_truthy
237
238
 
238
239
  doc2 = @document.new("name" => "blammo")
239
240
  doc2.should have_error_on(:name)
@@ -251,10 +252,10 @@ describe "Validations" do
251
252
 
252
253
  it "should check for uniqueness using entire string" do
253
254
  doc = @document.new("name" => "John Doe")
254
- doc.save.should be_true
255
+ doc.save.should be_truthy
255
256
 
256
257
  doc2 = @document.new("name" => "John")
257
- doc2.valid?.should be_true
258
+ doc2.valid?.should be_truthy
258
259
  end
259
260
  end
260
261
 
@@ -269,12 +270,12 @@ describe "Validations" do
269
270
 
270
271
  it "should fail if the same name exists in the scope" do
271
272
  doc = @document.new("name" => "joe", "scope" => "one")
272
- doc.save.should be_true
273
+ doc.save.should be_truthy
273
274
 
274
- @document \
275
- .stub(:first) \
276
- .with(:name => 'joe', :scope => "one") \
277
- .and_return(doc)
275
+ allow(@document).to \
276
+ receive(:first).
277
+ with(:name => 'joe', :scope => "one").
278
+ and_return(doc)
278
279
 
279
280
  doc2 = @document.new("name" => "joe", "scope" => "one")
280
281
  doc2.should have_error_on(:name)
@@ -282,12 +283,12 @@ describe "Validations" do
282
283
 
283
284
  it "should pass if the same name exists in a different scope" do
284
285
  doc = @document.new("name" => "joe", "scope" => "one")
285
- doc.save.should be_true
286
+ doc.save.should be_truthy
286
287
 
287
- @document \
288
- .stub(:first) \
289
- .with(:name => 'joe', :scope => 'two') \
290
- .and_return(nil)
288
+ allow(@document).to \
289
+ receive(:first).
290
+ with(:name => 'joe', :scope => 'two').
291
+ and_return(nil)
291
292
 
292
293
  doc2 = @document.new("name" => "joe", "scope" => "two")
293
294
  doc2.should_not have_error_on(:name)
@@ -306,12 +307,12 @@ describe "Validations" do
306
307
 
307
308
  it "should fail if the same name exists in the scope" do
308
309
  doc = @document.new("name" => "joe", "first_scope" => "one", "second_scope" => "two")
309
- doc.save.should be_true
310
+ doc.save.should be_truthy
310
311
 
311
- @document \
312
- .stub(:first) \
313
- .with(:name => 'joe', :first_scope => 'one', :second_scope => 'two') \
314
- .and_return(doc)
312
+ allow(@document).to \
313
+ receive(:first).
314
+ with(:name => 'joe', :first_scope => 'one', :second_scope => 'two').
315
+ and_return(doc)
315
316
 
316
317
  doc2 = @document.new("name" => "joe", "first_scope" => "one", "second_scope" => "two")
317
318
  doc2.should have_error_on(:name)
@@ -319,12 +320,12 @@ describe "Validations" do
319
320
 
320
321
  it "should pass if the same name exists in a different scope" do
321
322
  doc = @document.new("name" => "joe", "first_scope" => "one", "second_scope" => "two")
322
- doc.save.should be_true
323
+ doc.save.should be_truthy
323
324
 
324
- @document \
325
- .stub(:first) \
326
- .with(:name => 'joe', :first_scope => 'one', :second_scope => 'one') \
327
- .and_return(nil)
325
+ allow(@document).to \
326
+ receive(:first).
327
+ with(:name => 'joe', :first_scope => 'one', :second_scope => 'one').
328
+ and_return(nil)
328
329
 
329
330
  doc2 = @document.new("name" => "joe", "first_scope" => "one", "second_scope" => "one")
330
331
  doc2.should_not have_error_on(:name)
@@ -345,21 +346,21 @@ describe "Validations" do
345
346
 
346
347
  it "should pass if there are no associated docs" do
347
348
  doc = @root_class.new
348
- doc.save.should be_true
349
+ doc.save.should be_truthy
349
350
  end
350
351
 
351
352
  it "should pass if the associated doc is valid" do
352
353
  doc = @root_class.new
353
354
  doc.children.build(:name => 'Joe')
354
- doc.save.should be_true
355
+ doc.save.should be_truthy
355
356
  end
356
357
 
357
358
  it "should fail if the associated doc is invalid" do
358
359
  doc = @root_class.new
359
360
  doc.children.build
360
- doc.should have_error_on(:children, 'are invalid')
361
+ doc.should have_error_on(:children)
362
+ doc.errors[:children].should == ['are invalid']
361
363
  end
362
-
363
364
  end
364
365
 
365
366
  context "validating associated docs with custom context" do
@@ -377,22 +378,22 @@ describe "Validations" do
377
378
 
378
379
  it "should pass if there are no associated docs" do
379
380
  doc = @root_class.new
380
- doc.valid?(:custom_context).should be_true
381
+ doc.valid?(:custom_context).should be_truthy
381
382
  end
382
383
 
383
384
  it "should pass if the associated doc is valid" do
384
385
  doc = @root_class.new
385
386
  doc.children.build(:name => 'George')
386
- doc.valid?(:custom_context).should be_true
387
+ doc.valid?(:custom_context).should be_truthy
387
388
  end
388
389
 
389
390
  it "should fail if the associated doc is invalid" do
390
391
  doc = @root_class.new
391
392
  doc.children.build(:name => 'Bob')
392
- doc.valid?(:custom_context).should_not be_true
393
+ doc.valid?(:custom_context).should_not be_truthy
393
394
  end
394
-
395
395
  end
396
+
396
397
  # context "validates uniqueness of with :unique shortcut" do
397
398
  # it "should work" do
398
399
  # @document = Doc do
@@ -402,13 +403,14 @@ describe "Validations" do
402
403
  # doc = @document.create(:name => 'John')
403
404
  # doc.should_not have_error_on(:name)
404
405
  #
405
- # @document \
406
- # .stub(:first) \
407
- # .with(:name => 'John') \
408
- # .and_return(doc)
406
+ # allow(@document).to \
407
+ # receive(:first).
408
+ # with(:name => 'John').
409
+ # and_return(doc)
409
410
  #
410
411
  # second_john = @document.create(:name => 'John')
411
- # second_john.should have_error_on(:name, 'has already been taken')
412
+ # second_john.should have_error_on(:name)
413
+ # second_john.errors[:name].should == ['has already been taken']
412
414
  # end
413
415
  # end
414
416
  end
@@ -27,7 +27,7 @@ describe "The library itself" do
27
27
  end
28
28
 
29
29
  RSpec::Matchers.define :be_well_formed do
30
- failure_message_for_should do |actual|
30
+ failure_message do |actual|
31
31
  actual.join("\n")
32
32
  end
33
33
 
@@ -5,6 +5,7 @@ require 'bundler/setup'
5
5
  require 'fileutils'
6
6
  require 'timecop'
7
7
  require "generator_spec/test_case"
8
+ # require 'ruby-debug'
8
9
 
9
10
  if RUBY_PLATFORM != "java"
10
11
  if ENV['TRAVIS']
@@ -70,9 +71,12 @@ MongoMapper.database = "test"
70
71
  MongoMapper.database.collections.each { |c| c.drop_indexes }
71
72
  Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
72
73
 
73
- RSpec.configure do |c|
74
- c.treat_symbols_as_metadata_keys_with_true_values = true
75
- c.around(:each, :without_connection) do |example|
74
+ RSpec.configure do |config|
75
+ config.expect_with :rspec do |c|
76
+ c.syntax = [:should, :expect]
77
+ end
78
+
79
+ config.around(:each, :without_connection) do |example|
76
80
  old, MongoMapper.connection = MongoMapper.connection, nil
77
81
  example.run
78
82
  MongoMapper.connection = old