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
@@ -105,7 +105,7 @@ describe "ManyDocumentsProxy" do
105
105
  owner.pets[1].name.should == 'Sasha'
106
106
  owner.pets[1].species.should == 'Siberian Husky'
107
107
 
108
- owner.save.should be_true
108
+ owner.save.should be_truthy
109
109
  owner.reload
110
110
 
111
111
  owner.name.should == 'Mr. Pet Lover'
@@ -128,7 +128,7 @@ describe "ManyDocumentsProxy" do
128
128
  it "should work" do
129
129
  project = Project.new
130
130
  project.statuses = [Status.new(:name => "ready")]
131
- project.save.should be_true
131
+ project.save.should be_truthy
132
132
 
133
133
  project.reload
134
134
  project.statuses.size.should == 1
@@ -140,7 +140,7 @@ describe "ManyDocumentsProxy" do
140
140
  it "should convert to objects of the class and work" do
141
141
  project = Project.new
142
142
  project.statuses = [{ 'name' => 'ready' }]
143
- project.save.should be_true
143
+ project.save.should be_truthy
144
144
 
145
145
  project.reload
146
146
  project.statuses.size.should == 1
@@ -171,9 +171,9 @@ describe "ManyDocumentsProxy" do
171
171
  end
172
172
 
173
173
  it "should call destroy the existing documents" do
174
- @broker.properties[0].should_receive(:destroy).once
175
- @broker.properties[1].should_receive(:destroy).once
176
- @broker.properties[2].should_receive(:destroy).once
174
+ expect(@broker.properties[0]).to receive(:destroy).once
175
+ expect(@broker.properties[1]).to receive(:destroy).once
176
+ expect(@broker.properties[2]).to receive(:destroy).once
177
177
  @broker.properties = [@property_class.new]
178
178
  end
179
179
 
@@ -184,9 +184,9 @@ describe "ManyDocumentsProxy" do
184
184
  end
185
185
 
186
186
  it "should skip over documents that are the same" do
187
- @broker.properties[0].should_receive(:destroy).never
188
- @broker.properties[1].should_receive(:destroy).once
189
- @broker.properties[2].should_receive(:destroy).never
187
+ expect(@broker.properties[0]).to receive(:destroy).never
188
+ expect(@broker.properties[1]).to receive(:destroy).once
189
+ expect(@broker.properties[2]).to receive(:destroy).never
190
190
  @broker.properties = [@property3, @property1]
191
191
  end
192
192
  end
@@ -205,9 +205,9 @@ describe "ManyDocumentsProxy" do
205
205
  end
206
206
 
207
207
  it "should call delete the existing documents" do
208
- @broker.properties[0].should_receive(:delete).once
209
- @broker.properties[1].should_receive(:delete).once
210
- @broker.properties[2].should_receive(:delete).once
208
+ expect(@broker.properties[0]).to receive(:delete).once
209
+ expect(@broker.properties[1]).to receive(:delete).once
210
+ expect(@broker.properties[2]).to receive(:delete).once
211
211
  @broker.properties = [@property_class.new]
212
212
  end
213
213
 
@@ -218,9 +218,9 @@ describe "ManyDocumentsProxy" do
218
218
  end
219
219
 
220
220
  it "should skip over documents that are the same" do
221
- @broker.properties[0].should_receive(:delete).never
222
- @broker.properties[1].should_receive(:delete).once
223
- @broker.properties[2].should_receive(:delete).never
221
+ expect(@broker.properties[0]).to receive(:delete).never
222
+ expect(@broker.properties[1]).to receive(:delete).once
223
+ expect(@broker.properties[2]).to receive(:delete).never
224
224
  @broker.properties = [@property3, @property1]
225
225
  end
226
226
  end
@@ -491,19 +491,19 @@ describe "ManyDocumentsProxy" do
491
491
  context "empty?" do
492
492
  it "should be true with no associated docs" do
493
493
  project = Project.create
494
- project.statuses.empty?.should be_true
494
+ project.statuses.empty?.should be_truthy
495
495
  end
496
496
 
497
497
  it "should be false if a document is built" do
498
498
  project = Project.create
499
499
  project.statuses.build(:name => 'Foo!')
500
- project.statuses.empty?.should be_false
500
+ project.statuses.empty?.should be_falsey
501
501
  end
502
502
 
503
503
  it "should be false if a document is created" do
504
504
  project = Project.create
505
505
  project.statuses.create(:name => 'Foo!')
506
- project.statuses.empty?.should be_false
506
+ project.statuses.empty?.should be_falsey
507
507
  end
508
508
  end
509
509
 
@@ -950,4 +950,75 @@ describe "ManyDocumentsProxy" do
950
950
  @paper.articles.should include(article)
951
951
  end
952
952
  end
953
+
954
+ describe "regression with association proxy scoping" do
955
+ before do
956
+ @job_title_class = Doc do
957
+ set_collection_name "job_titles"
958
+ end
959
+
960
+ @training_class = Doc do
961
+ set_collection_name "trainings"
962
+ key :slug, String
963
+ key :is_active, Boolean, default: true
964
+
965
+ def self.find_by_slug!(the_slug)
966
+ if res = first(:slug => the_slug)
967
+ res
968
+ else
969
+ raise "MissingSlugError"
970
+ end
971
+ end
972
+
973
+ validates_presence_of :job_title_id
974
+ validates_presence_of :slug
975
+ validates_uniqueness_of :slug, :scope => :job_title_id
976
+ end
977
+
978
+ @job_title_class.has_many :trainings, :class => @training_class, :foreign_key => :job_title_id
979
+ @training_class.belongs_to :job_title, :class => @job_title_class
980
+ end
981
+
982
+ it "should scope queries that return a single method on has many association with the right parent id" do
983
+ @job_title_1 = @job_title_class.create!
984
+ @job_title_2 = @job_title_class.create!
985
+
986
+ @training_1 = @training_class.create!(:slug => 'foo', :job_title_id => @job_title_1.id)
987
+ @training_2 = @training_class.create!(:slug => 'foo', :job_title_id => @job_title_2.id)
988
+
989
+ @job_title_1.reload
990
+ @job_title_2.reload
991
+
992
+ @job_title_1.trainings.count.should == 1
993
+ @job_title_2.trainings.count.should == 1
994
+
995
+ @job_title_1.trainings.find_by_slug!('foo').should == @training_1
996
+ @job_title_2.trainings.find_by_slug!('foo').should == @training_2
997
+
998
+ lambda do
999
+ @job_title_2.trainings.find_by_slug!('bar')
1000
+ end.should raise_error
1001
+ end
1002
+
1003
+ it "should scope with an extra where clause on the proxy (regression #2)" do
1004
+ @job_title_1 = @job_title_class.create!
1005
+ @job_title_2 = @job_title_class.create!
1006
+
1007
+ @training_1 = @training_class.create!(:slug => 'foo', :job_title_id => @job_title_1.id)
1008
+ @training_2 = @training_class.create!(:slug => 'foo', :job_title_id => @job_title_2.id)
1009
+
1010
+ @job_title_1.reload
1011
+ @job_title_2.reload
1012
+
1013
+ @job_title_1.trainings.count.should == 1
1014
+ @job_title_2.trainings.count.should == 1
1015
+
1016
+ @job_title_1.trainings.where(:is_active => true).find_by_slug!('foo').should == @training_1
1017
+ @job_title_2.trainings.where(:is_active => true).find_by_slug!('foo').should == @training_2
1018
+
1019
+ lambda do
1020
+ @job_title_2.trainings.find_by_slug!('bar')
1021
+ end.should raise_error
1022
+ end
1023
+ end
953
1024
  end
@@ -21,7 +21,7 @@ describe "ManyEmbeddedPolymorphicProxy" do
21
21
  it "should be able to replace the association" do
22
22
  catalog = Catalog.new
23
23
  catalog.medias = [Video.new('file' => 'video.mpg', 'length' => 3600)]
24
- catalog.save.should be_true
24
+ catalog.save.should be_truthy
25
25
 
26
26
  catalog = catalog.reload
27
27
  catalog.medias.size.should == 1
@@ -40,7 +40,7 @@ describe "ManyEmbeddedPolymorphicProxy" do
40
40
  catalog.medias[1].serial_number.should == '1B'
41
41
  catalog.medias[1].class.should == Robot
42
42
 
43
- catalog.save.should be_true
43
+ catalog.save.should be_truthy
44
44
  catalog.reload
45
45
 
46
46
  catalog.medias.size.should == 2
@@ -60,7 +60,7 @@ describe "ManyEmbeddedPolymorphicProxy" do
60
60
  catalog.medias[1].serial_number.should == '1B'
61
61
  catalog.medias[1].class.should == Robot
62
62
 
63
- catalog.save.should be_true
63
+ catalog.save.should be_truthy
64
64
  catalog.reload
65
65
 
66
66
  catalog.medias.size.should == 2
@@ -81,7 +81,7 @@ describe "ManyEmbeddedPolymorphicProxy" do
81
81
  catalog.medias[1].serial_number.should == '1B'
82
82
  catalog.medias[1].class.should == Robot
83
83
 
84
- catalog.save.should be_true
84
+ catalog.save.should be_truthy
85
85
  catalog.reload
86
86
 
87
87
  catalog.medias.size.should == 2
@@ -105,7 +105,7 @@ describe "ManyEmbeddedPolymorphicProxy" do
105
105
  Image.new('file' => 'image.png', 'width' => 800, 'height' => 600)
106
106
  ]
107
107
  catalog.medias.count.should == 3
108
- catalog.save.should be_true
108
+ catalog.save.should be_truthy
109
109
  catalog.reload
110
110
  catalog.medias.count.should == 3
111
111
  end
@@ -118,7 +118,7 @@ describe "ManyEmbeddedPolymorphicProxy" do
118
118
  Music.new('file' => 'music.mp3', 'bitrate' => '128kbps'),
119
119
  Image.new('file' => 'image.png', 'width' => 800, 'height' => 600)
120
120
  ]
121
- catalog.save.should be_true
121
+ catalog.save.should be_truthy
122
122
 
123
123
  catalog = catalog.reload
124
124
  catalog.medias.size.should == 3
@@ -146,7 +146,7 @@ describe "ManyEmbeddedPolymorphicProxy" do
146
146
  fleet.transports.size.should == 3
147
147
  fleet.transports[0].class.should == TrModels::Ambulance
148
148
  fleet.transports[0].license_plate.should == 'GGG123'
149
- fleet.transports[0].icu.should be_true
149
+ fleet.transports[0].icu.should be_truthy
150
150
  fleet.transports[1].class.should == TrModels::Car
151
151
  fleet.transports[1].license_plate.should == 'ABC123'
152
152
  fleet.transports[1].model.should == 'VW Golf'
@@ -155,12 +155,12 @@ describe "ManyEmbeddedPolymorphicProxy" do
155
155
  fleet.transports[2].license_plate.should == 'DEF123'
156
156
  fleet.transports[2].model.should == 'Honda Accord'
157
157
  fleet.transports[2].year.should == 2008
158
- fleet.save.should be_true
158
+ fleet.save.should be_truthy
159
159
 
160
160
  fleet = fleet.reload
161
161
  fleet.transports.size.should == 3
162
162
  fleet.transports[0].license_plate.should == 'GGG123'
163
- fleet.transports[0].icu.should be_true
163
+ fleet.transports[0].icu.should be_truthy
164
164
  fleet.transports[1].license_plate.should == 'ABC123'
165
165
  fleet.transports[1].model.should == 'VW Golf'
166
166
  fleet.transports[1].year.should == 2001
@@ -184,7 +184,7 @@ describe "ManyEmbeddedPolymorphicProxy" do
184
184
  it "should be able to replace the association" do
185
185
  fleet = TrModels::Fleet.new
186
186
  fleet.transports = [TrModels::Car.new('license_plate' => 'DCU2013', 'model' => 'Honda Civic')]
187
- fleet.save.should be_true
187
+ fleet.save.should be_truthy
188
188
 
189
189
  fleet = fleet.reload
190
190
  fleet.transports.size.should == 1
@@ -198,7 +198,7 @@ describe "ManyEmbeddedPolymorphicProxy" do
198
198
  TrModels::Bus.new('license_plate' => 'XYZ9090', 'max_passengers' => 51),
199
199
  TrModels::Ambulance.new('license_plate' => 'HDD3030', 'icu' => true)
200
200
  ]
201
- fleet.save.should be_true
201
+ fleet.save.should be_truthy
202
202
 
203
203
  fleet = fleet.reload
204
204
  fleet.transports.size.should == 3
@@ -89,7 +89,7 @@ describe "ManyEmbeddedProxy" do
89
89
  owner.pets[1].name.should == 'Sasha'
90
90
  owner.pets[1].species.should == 'Siberian Husky'
91
91
 
92
- owner.save.should be_true
92
+ owner.save.should be_truthy
93
93
  owner.reload
94
94
 
95
95
  owner.name.should == 'Mr. Pet Lover'
@@ -9,7 +9,7 @@ describe "OneAsProxy" do
9
9
 
10
10
  it "should default to nil" do
11
11
  @post_class.one :author, :as => :authorable, :class => @author_class
12
- @post_class.new.author.nil?.should be_true
12
+ @post_class.new.author.nil?.should be_truthy
13
13
  end
14
14
 
15
15
  it "should return nil instead of a proxy" do
@@ -29,7 +29,7 @@ describe "OneAsProxy" do
29
29
  post = @post_class.new('author' => { 'name' => 'Frank' })
30
30
  post.author.name.should == 'Frank'
31
31
 
32
- post.save.should be_true
32
+ post.save.should be_truthy
33
33
  post.reload
34
34
 
35
35
  post.author.name.should == 'Frank'
@@ -59,7 +59,7 @@ describe "OneAsProxy" do
59
59
  @post.reload
60
60
 
61
61
  @post.author.should == @author
62
- @post.author.nil?.should be_false
62
+ @post.author.nil?.should be_falsey
63
63
 
64
64
  new_author = @author_class.new(:name => 'Emily')
65
65
  @post.author = new_author
@@ -71,7 +71,7 @@ describe "OneAsProxy" do
71
71
  @post.reload
72
72
 
73
73
  @post.author.should == @author
74
- @post.author.nil?.should be_false
74
+ @post.author.nil?.should be_falsey
75
75
 
76
76
  original_author = @post.author
77
77
  original_author.name.should == 'Frank'
@@ -104,7 +104,7 @@ describe "OneAsProxy" do
104
104
  @post.reload
105
105
 
106
106
  @post.author.name.should == 'Frank'
107
- @post.author.nil?.should be_false
107
+ @post.author.nil?.should be_falsey
108
108
 
109
109
  @post.author = {'name' => 'Emily'}
110
110
  @post.author.name.should == 'Emily'
@@ -132,7 +132,7 @@ describe "OneAsProxy" do
132
132
  end
133
133
 
134
134
  it "should call delete on the existing document" do
135
- @author_class.any_instance.should_receive(:delete).once
135
+ expect_any_instance_of(@author_class).to receive(:delete).once
136
136
  @post.author = @author_class.new
137
137
  end
138
138
 
@@ -142,7 +142,7 @@ describe "OneAsProxy" do
142
142
  end
143
143
 
144
144
  it "should do nothing if it's the same document" do
145
- @author_class.any_instance.should_receive(:delete).never
145
+ expect_any_instance_of(@author_class).to receive(:delete).never
146
146
  @post.author = @author
147
147
  end
148
148
  end
@@ -157,7 +157,7 @@ describe "OneAsProxy" do
157
157
  end
158
158
 
159
159
  it "should call destroy the existing document" do
160
- @author_class.any_instance.should_receive(:destroy).once
160
+ expect_any_instance_of(@author_class).to receive(:destroy).once
161
161
  @post.author = @author_class.new
162
162
  end
163
163
 
@@ -167,7 +167,7 @@ describe "OneAsProxy" do
167
167
  end
168
168
 
169
169
  it "should do nothing if it's the same document" do
170
- @author_class.any_instance.should_receive(:destroy).never
170
+ expect_any_instance_of(@author_class).to receive(:destroy).never
171
171
  @post.author = @author
172
172
  end
173
173
  end
@@ -263,10 +263,10 @@ describe "OneAsProxy" do
263
263
  @post_class.one :author, :as => :authorable, :class => @author_class
264
264
 
265
265
  post = @post_class.new
266
- post.author?.should be_false
266
+ post.author?.should be_falsey
267
267
 
268
268
  post.author = @author_class.new(:name => 'Frank')
269
- post.author?.should be_true
269
+ post.author?.should be_truthy
270
270
  end
271
271
 
272
272
  it "should work with criteria" do
@@ -288,7 +288,7 @@ describe "OneAsProxy" do
288
288
  post.update_attributes!(:author => author)
289
289
  post.reload
290
290
  post.author = nil
291
- post.author.nil?.should be_true
291
+ post.author.nil?.should be_truthy
292
292
  end
293
293
 
294
294
  context "destroying parent with :dependent" do
@@ -302,7 +302,7 @@ describe "OneAsProxy" do
302
302
  end
303
303
 
304
304
  it "should should call destroy on the associated documents" do
305
- @author_class.any_instance.should_receive(:destroy).once
305
+ expect_any_instance_of(@author_class).to receive(:destroy).once
306
306
  @post.destroy
307
307
  end
308
308
 
@@ -324,7 +324,7 @@ describe "OneAsProxy" do
324
324
  end
325
325
 
326
326
  it "should should call delete the associated documents" do
327
- @author_class.any_instance.should_receive(:delete).once
327
+ expect_any_instance_of(@author_class).to receive(:delete).once
328
328
  @post.destroy
329
329
  end
330
330
 
@@ -35,7 +35,7 @@ describe "OneEmbeddedPolymorhpicProxy" do
35
35
  post.author.name.should == 'Frank'
36
36
  post.author.class.should == Human
37
37
 
38
- post.save.should be_true
38
+ post.save.should be_truthy
39
39
  post.reload
40
40
 
41
41
  post.author.name.should == 'Frank'
@@ -56,7 +56,7 @@ describe "OneEmbeddedPolymorhpicProxy" do
56
56
  @post.reload
57
57
 
58
58
  @post.author.should == @human
59
- @post.author.nil?.should be_false
59
+ @post.author.nil?.should be_falsey
60
60
  @post.author.class.should == Human
61
61
 
62
62
  new_human = Human.new(:name => 'Emily')
@@ -70,7 +70,7 @@ describe "OneEmbeddedPolymorhpicProxy" do
70
70
  @post.reload
71
71
 
72
72
  @post.author.should == @human
73
- @post.author.nil?.should be_false
73
+ @post.author.nil?.should be_falsey
74
74
 
75
75
  original_author = @post.author
76
76
  original_author.name.should == 'Frank'
@@ -99,7 +99,7 @@ describe "OneEmbeddedPolymorhpicProxy" do
99
99
  @post.reload
100
100
 
101
101
  @post.author.serial_number.should == '1B'
102
- @post.author.nil?.should be_false
102
+ @post.author.nil?.should be_falsey
103
103
 
104
104
  @post.author = {'serial_number' => '2C'}
105
105
  @post.author.serial_number.should == '2C'
@@ -142,13 +142,13 @@ describe "OneEmbeddedPolymorhpicProxy" do
142
142
 
143
143
  post.author.class.should == TrModels::Ambulance
144
144
  post.author.license_plate.should == 'GGG123'
145
- post.author.icu.should be_true
146
- post.save.should be_true
145
+ post.author.icu.should be_truthy
146
+ post.save.should be_truthy
147
147
 
148
148
  post = post.reload
149
149
  post.author.class.should == TrModels::Ambulance
150
150
  post.author.license_plate.should == 'GGG123'
151
- post.author.icu.should be_true
151
+ post.author.icu.should be_truthy
152
152
  end
153
153
 
154
154
  it "should not have problem loading root document if embedded one is nil" do
@@ -179,10 +179,10 @@ describe "OneEmbeddedPolymorhpicProxy" do
179
179
  @post_class.one :author, :polymorphic => true, :class => Robot
180
180
 
181
181
  post = @post_class.new
182
- post.author?.should be_false
182
+ post.author?.should be_falsey
183
183
 
184
184
  post.author = Human.new(:name => 'Frank')
185
- post.author?.should be_true
185
+ post.author?.should be_truthy
186
186
  end
187
187
 
188
188
  it "should initialize id for nested embedded document created from hash" do