couchrest_model 2.1.0.rc1 → 2.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +15 -4
  4. data/Gemfile.activesupport-4.x +4 -0
  5. data/Gemfile.activesupport-5.x +4 -0
  6. data/README.md +2 -0
  7. data/VERSION +1 -1
  8. data/couchrest_model.gemspec +3 -2
  9. data/history.md +14 -1
  10. data/lib/couchrest/model/associations.rb +3 -8
  11. data/lib/couchrest/model/base.rb +15 -7
  12. data/lib/couchrest/model/casted_array.rb +22 -34
  13. data/lib/couchrest/model/configuration.rb +2 -0
  14. data/lib/couchrest/model/design.rb +4 -3
  15. data/lib/couchrest/model/designs/view.rb +37 -32
  16. data/lib/couchrest/model/dirty.rb +93 -19
  17. data/lib/couchrest/model/embeddable.rb +2 -14
  18. data/lib/couchrest/model/extended_attachments.rb +2 -4
  19. data/lib/couchrest/model/persistence.rb +14 -17
  20. data/lib/couchrest/model/properties.rb +46 -54
  21. data/lib/couchrest/model/property.rb +0 -3
  22. data/lib/couchrest/model/proxyable.rb +20 -4
  23. data/lib/couchrest/model/validations/uniqueness.rb +4 -1
  24. data/lib/couchrest_model.rb +2 -2
  25. data/spec/fixtures/models/article.rb +1 -1
  26. data/spec/fixtures/models/card.rb +2 -1
  27. data/spec/fixtures/models/person.rb +1 -0
  28. data/spec/fixtures/models/project.rb +3 -0
  29. data/spec/unit/assocations_spec.rb +73 -73
  30. data/spec/unit/attachment_spec.rb +34 -34
  31. data/spec/unit/base_spec.rb +102 -102
  32. data/spec/unit/casted_array_spec.rb +7 -7
  33. data/spec/unit/casted_spec.rb +7 -7
  34. data/spec/unit/configuration_spec.rb +11 -11
  35. data/spec/unit/connection_spec.rb +30 -30
  36. data/spec/unit/core_extensions/{time_parsing.rb → time_parsing_spec.rb} +21 -21
  37. data/spec/unit/design_spec.rb +38 -38
  38. data/spec/unit/designs/design_mapper_spec.rb +26 -26
  39. data/spec/unit/designs/migrations_spec.rb +13 -13
  40. data/spec/unit/designs/view_spec.rb +319 -274
  41. data/spec/unit/designs_spec.rb +39 -39
  42. data/spec/unit/dirty_spec.rb +188 -103
  43. data/spec/unit/embeddable_spec.rb +119 -117
  44. data/spec/unit/inherited_spec.rb +4 -4
  45. data/spec/unit/persistence_spec.rb +122 -122
  46. data/spec/unit/properties_spec.rb +466 -16
  47. data/spec/unit/property_protection_spec.rb +32 -32
  48. data/spec/unit/property_spec.rb +45 -436
  49. data/spec/unit/proxyable_spec.rb +140 -82
  50. data/spec/unit/subclass_spec.rb +14 -14
  51. data/spec/unit/translations_spec.rb +5 -5
  52. data/spec/unit/typecast_spec.rb +131 -131
  53. data/spec/unit/utils/migrate_spec.rb +2 -2
  54. data/spec/unit/validations_spec.rb +31 -31
  55. metadata +27 -12
  56. data/lib/couchrest/model/casted_hash.rb +0 -84
@@ -18,15 +18,15 @@ end
18
18
 
19
19
  describe "Using chained inheritance without CouchRest::Model::Base" do
20
20
  it "should preserve inheritable attributes" do
21
- PlainParent.foo.should == :bar
22
- PlainChild.foo.should == :bar
21
+ expect(PlainParent.foo).to eq(:bar)
22
+ expect(PlainChild.foo).to eq(:bar)
23
23
  end
24
24
  end
25
25
 
26
26
  describe "Using chained inheritance with CouchRest::Model::Base" do
27
27
  it "should preserve inheritable attributes" do
28
- ExtendedParent.foo.should == :bar
29
- ExtendedChild.foo.should == :bar
28
+ expect(ExtendedParent.foo).to eq(:bar)
29
+ expect(ExtendedChild.foo).to eq(:bar)
30
30
  end
31
31
  end
32
32
 
@@ -11,17 +11,17 @@ describe CouchRest::Model::Persistence do
11
11
 
12
12
  it "should instantialize" do
13
13
  doc = Article.build_from_database({'_id' => 'testitem1', '_rev' => 123, 'couchrest-type' => 'Article', 'name' => 'my test'})
14
- doc.class.should eql(Article)
14
+ expect(doc.class).to eql(Article)
15
15
  end
16
16
 
17
17
  it "should instantialize of same class if no couchrest-type included from DB" do
18
18
  doc = Article.build_from_database({'_id' => 'testitem1', '_rev' => 123, 'name' => 'my test'})
19
- doc.class.should eql(Article)
19
+ expect(doc.class).to eql(Article)
20
20
  end
21
21
 
22
22
  it "should instantiate document of different type" do
23
23
  doc = Article.build_from_database({'_id' => 'testitem2', '_rev' => 123, Article.model_type_key => 'WithTemplateAndUniqueID', 'name' => 'my test'})
24
- doc.class.should eql(WithTemplateAndUniqueID)
24
+ expect(doc.class).to eql(WithTemplateAndUniqueID)
25
25
  end
26
26
 
27
27
  end
@@ -32,16 +32,16 @@ describe CouchRest::Model::Persistence do
32
32
  @obj.name = "should be easily saved and retrieved"
33
33
  @obj.save!
34
34
  saved_obj = WithDefaultValues.get!(@obj.id)
35
- saved_obj.should_not be_nil
35
+ expect(saved_obj).not_to be_nil
36
36
  end
37
37
 
38
38
  it "should parse the Time attributes automatically" do
39
39
  @obj.name = "should parse the Time attributes automatically"
40
- @obj.set_by_proc.should be_an_instance_of(Time)
40
+ expect(@obj.set_by_proc).to be_an_instance_of(Time)
41
41
  @obj.save
42
- @obj.set_by_proc.should be_an_instance_of(Time)
42
+ expect(@obj.set_by_proc).to be_an_instance_of(Time)
43
43
  saved_obj = WithDefaultValues.get(@obj.id)
44
- saved_obj.set_by_proc.should be_an_instance_of(Time)
44
+ expect(saved_obj.set_by_proc).to be_an_instance_of(Time)
45
45
  end
46
46
  end
47
47
 
@@ -52,49 +52,49 @@ describe CouchRest::Model::Persistence do
52
52
  end
53
53
 
54
54
  it "should accept true or false on save for validation" do
55
- @sobj.should_receive(:valid?)
55
+ expect(@sobj).to receive(:valid?)
56
56
  @sobj.save(true)
57
57
  end
58
58
 
59
59
  it "should accept hash with validation option" do
60
- @sobj.should_receive(:valid?)
60
+ expect(@sobj).to receive(:valid?)
61
61
  @sobj.save(:validate => true)
62
62
  end
63
63
 
64
64
  it "should not call validation when option is false" do
65
- @sobj.should_not_receive(:valid?)
65
+ expect(@sobj).not_to receive(:valid?)
66
66
  @sobj.save(false)
67
67
  end
68
68
 
69
69
  it "should not call validation when option :validate is false" do
70
- @sobj.should_not_receive(:valid?)
70
+ expect(@sobj).not_to receive(:valid?)
71
71
  @sobj.save(:validate => false)
72
72
  end
73
73
 
74
74
  it "should instantialize and save a document" do
75
75
  article = Article.create(:title => 'my test')
76
- article.title.should == 'my test'
77
- article.should_not be_new
76
+ expect(article.title).to eq('my test')
77
+ expect(article).not_to be_new
78
78
  end
79
79
 
80
80
  it "yields new instance to block before saving (#create)" do
81
81
  article = Article.create{|a| a.title = 'my create init block test'}
82
- article.title.should == 'my create init block test'
83
- article.should_not be_new
82
+ expect(article.title).to eq('my create init block test')
83
+ expect(article).not_to be_new
84
84
  end
85
85
 
86
86
  it "yields new instance to block before saving (#create!)" do
87
87
  article = Article.create{|a| a.title = 'my create bang init block test'}
88
- article.title.should == 'my create bang init block test'
89
- article.should_not be_new
88
+ expect(article.title).to eq('my create bang init block test')
89
+ expect(article).not_to be_new
90
90
  end
91
91
 
92
92
  it "should trigger the create callbacks" do
93
93
  doc = WithCallBacks.create(:name => 'my other test')
94
- doc.run_before_create.should be_true
95
- doc.run_after_create.should be_true
96
- doc.run_before_save.should be_true
97
- doc.run_after_save.should be_true
94
+ expect(doc.run_before_create).to be_truthy
95
+ expect(doc.run_after_create).to be_truthy
96
+ expect(doc.run_before_save).to be_truthy
97
+ expect(doc.run_after_save).to be_truthy
98
98
  end
99
99
 
100
100
  end
@@ -102,46 +102,46 @@ describe CouchRest::Model::Persistence do
102
102
  describe "saving a model" do
103
103
  before(:all) do
104
104
  @sobj = Basic.new
105
- @sobj.save.should be_true
105
+ expect(@sobj.save).to be_truthy
106
106
  end
107
107
 
108
108
  it "should save the doc" do
109
109
  doc = Basic.get(@sobj.id)
110
- doc['_id'].should == @sobj.id
110
+ expect(doc['_id']).to eq(@sobj.id)
111
111
  end
112
112
 
113
113
  it "should be set for resaving" do
114
114
  rev = @obj.rev
115
115
  @sobj['another-key'] = "some value"
116
116
  @sobj.save
117
- @sobj.rev.should_not == rev
117
+ expect(@sobj.rev).not_to eq(rev)
118
118
  end
119
119
 
120
120
  it "should set the id" do
121
- @sobj.id.should be_an_instance_of(String)
121
+ expect(@sobj.id).to be_an_instance_of(String)
122
122
  end
123
123
 
124
124
  it "should set the type" do
125
- @sobj[@sobj.model_type_key].should == 'Basic'
125
+ expect(@sobj[@sobj.model_type_key]).to eq('Basic')
126
126
  end
127
127
 
128
128
  it "should accept true or false on save for validation" do
129
- @sobj.should_receive(:valid?)
129
+ expect(@sobj).to receive(:valid?)
130
130
  @sobj.save(true)
131
131
  end
132
132
 
133
133
  it "should accept hash with validation option" do
134
- @sobj.should_receive(:valid?)
134
+ expect(@sobj).to receive(:valid?)
135
135
  @sobj.save(:validate => true)
136
136
  end
137
137
 
138
138
  it "should not call validation when option is false" do
139
- @sobj.should_not_receive(:valid?)
139
+ expect(@sobj).not_to receive(:valid?)
140
140
  @sobj.save(false)
141
141
  end
142
142
 
143
143
  it "should not call validation when option :validate is false" do
144
- @sobj.should_not_receive(:valid?)
144
+ expect(@sobj).not_to receive(:valid?)
145
145
  @sobj.save(:validate => false)
146
146
  end
147
147
 
@@ -152,12 +152,12 @@ describe CouchRest::Model::Persistence do
152
152
  end
153
153
 
154
154
  it "should return true if save the document" do
155
- @sobj.save!.should be_true
155
+ expect(@sobj.save!).to be_truthy
156
156
  end
157
157
 
158
158
  it "should raise error if don't save the document" do
159
159
  @sobj.first_name = nil
160
- lambda { @sobj.save! }.should raise_error(CouchRest::Model::Errors::Validations)
160
+ expect { @sobj.save! }.to raise_error(CouchRest::Model::Errors::Validations)
161
161
  end
162
162
 
163
163
  end
@@ -171,41 +171,41 @@ describe CouchRest::Model::Persistence do
171
171
  end
172
172
 
173
173
  it "should be a new document" do
174
- @art.should be_new
175
- @art.title.should be_nil
174
+ expect(@art).to be_new
175
+ expect(@art.title).to be_nil
176
176
  end
177
177
 
178
178
  it "should require the title" do
179
- lambda{@art.save}.should raise_error
179
+ expect{@art.save}.to raise_error(/unique_id cannot be nil/)
180
180
  @art.title = 'This is the title'
181
- @art.save.should be_true
181
+ expect(@art.save).to be_truthy
182
182
  end
183
183
 
184
184
  it "should not change the slug on update" do
185
185
  @art.title = 'This is the title'
186
- @art.save.should be_true
186
+ expect(@art.save).to be_truthy
187
187
  @art.title = 'new title'
188
- @art.save.should be_true
189
- @art.slug.should == 'this-is-the-title'
188
+ expect(@art.save).to be_truthy
189
+ expect(@art.slug).to eq('this-is-the-title')
190
190
  end
191
191
 
192
192
  it "should raise an error when the slug is taken" do
193
193
  @art.title = 'This is the title'
194
- @art.save.should be_true
194
+ expect(@art.save).to be_truthy
195
195
  @art2 = Article.new(:title => 'This is the title!')
196
- lambda{@art2.save}.should raise_error
196
+ expect{@art2.save}.to raise_error(/409 Conflict/)
197
197
  end
198
198
 
199
199
  it "should set the slug" do
200
200
  @art.title = 'This is the title'
201
- @art.save.should be_true
202
- @art.slug.should == 'this-is-the-title'
201
+ expect(@art.save).to be_truthy
202
+ expect(@art.slug).to eq('this-is-the-title')
203
203
  end
204
204
 
205
205
  it "should set the id" do
206
206
  @art.title = 'This is the title'
207
- @art.save.should be_true
208
- @art.id.should == 'this-is-the-title'
207
+ expect(@art.save).to be_truthy
208
+ expect(@art.id).to eq('this-is-the-title')
209
209
  end
210
210
  end
211
211
 
@@ -217,48 +217,48 @@ describe CouchRest::Model::Persistence do
217
217
  end
218
218
 
219
219
  it "should require the field" do
220
- lambda{@templated.save}.should raise_error
220
+ expect{@templated.save}.to raise_error(/unique_id cannot be nil/)
221
221
  @templated['slug'] = 'very-important'
222
- @templated.save.should be_true
222
+ expect(@templated.save).to be_truthy
223
223
  end
224
224
 
225
225
  it "should save with the id" do
226
226
  @templated['slug'] = 'very-important'
227
- @templated.save.should be_true
227
+ expect(@templated.save).to be_truthy
228
228
  t = WithTemplateAndUniqueID.get('very-important')
229
- t.should == @templated
229
+ expect(t).to eq(@templated)
230
230
  end
231
231
 
232
232
  it "should not change the id on update" do
233
233
  @templated['slug'] = 'very-important'
234
- @templated.save.should be_true
234
+ expect(@templated.save).to be_truthy
235
235
  @templated['slug'] = 'not-important'
236
- @templated.save.should be_true
236
+ expect(@templated.save).to be_truthy
237
237
  t = WithTemplateAndUniqueID.get('very-important')
238
- t.id.should == @templated.id
238
+ expect(t.id).to eq(@templated.id)
239
239
  end
240
240
 
241
241
  it "should raise an error when the id is taken" do
242
242
  @templated['slug'] = 'very-important'
243
- @templated.save.should be_true
244
- lambda{WithTemplateAndUniqueID.new('slug' => 'very-important').save}.should raise_error
243
+ expect(@templated.save).to be_truthy
244
+ expect{WithTemplateAndUniqueID.new('slug' => 'very-important').save}.to raise_error(/409 Conflict/)
245
245
  end
246
246
 
247
247
  it "should set the id" do
248
248
  @templated['slug'] = 'very-important'
249
- @templated.save.should be_true
250
- @templated.id.should == 'very-important'
249
+ expect(@templated.save).to be_truthy
250
+ expect(@templated.id).to eq('very-important')
251
251
  end
252
252
  end
253
253
 
254
254
  describe "destroying an instance" do
255
255
  before(:each) do
256
256
  @dobj = Event.new
257
- @dobj.save.should be_true
257
+ expect(@dobj.save).to be_truthy
258
258
  end
259
259
  it "should return true" do
260
260
  result = @dobj.destroy
261
- result.should be_true
261
+ expect(result).to be_truthy
262
262
  end
263
263
  it "should make it go away" do
264
264
  @dobj.destroy
@@ -267,17 +267,17 @@ describe CouchRest::Model::Persistence do
267
267
  it "should freeze the object" do
268
268
  @dobj.destroy
269
269
  # In Ruby 1.9.2 this raises RuntimeError, in 1.8.7 TypeError, D'OH!
270
- lambda { @dobj.subject = "Test" }.should raise_error(StandardError)
270
+ expect { @dobj.subject = "Test" }.to raise_error(StandardError)
271
271
  end
272
272
  it "trying to save after should fail" do
273
273
  @dobj.destroy
274
- lambda { @dobj.save }.should raise_error(StandardError)
274
+ expect { @dobj.save }.to raise_error(StandardError)
275
275
  expect(Basic.get(@dobj.id)).to be_nil
276
276
  end
277
277
  it "should make destroyed? true" do
278
- @dobj.destroyed?.should be_false
278
+ expect(@dobj.destroyed?).to be_falsey
279
279
  @dobj.destroy
280
- @dobj.destroyed?.should be_true
280
+ expect(@dobj.destroyed?).to be_truthy
281
281
  end
282
282
  end
283
283
 
@@ -289,18 +289,18 @@ describe CouchRest::Model::Persistence do
289
289
  end
290
290
  it "should load and instantiate it" do
291
291
  foundart = Article.get @art.id
292
- foundart.title.should == "All About Getting"
292
+ expect(foundart.title).to eq("All About Getting")
293
293
  end
294
294
  it "should load and instantiate with find" do
295
295
  foundart = Article.find @art.id
296
- foundart.title.should == "All About Getting"
296
+ expect(foundart.title).to eq("All About Getting")
297
297
  end
298
298
  it "should return nil if `get` is used and the document doesn't exist" do
299
299
  foundart = Article.get 'matt aimonetti'
300
- foundart.should be_nil
300
+ expect(foundart).to be_nil
301
301
  end
302
302
  it "should return nil if a blank id is requested" do
303
- Article.get("").should be_nil
303
+ expect(Article.get("")).to be_nil
304
304
  end
305
305
  it "should raise an error if `get!` is used and the document doesn't exist" do
306
306
  expect{ Article.get!('matt aimonetti') }.to raise_error(CouchRest::Model::DocumentNotFound)
@@ -313,7 +313,7 @@ describe CouchRest::Model::Persistence do
313
313
  end
314
314
  context "without a database" do
315
315
  it "should cause #get to raise an error" do
316
- Article.stub(:database).and_return(nil)
316
+ allow(Article).to receive(:database).and_return(nil)
317
317
  expect{ Article.get('foo') }.to raise_error(CouchRest::Model::DatabaseNotDefined)
318
318
  expect{ Article.get!('foo') }.to raise_error(CouchRest::Model::DatabaseNotDefined)
319
319
  end
@@ -339,10 +339,10 @@ describe CouchRest::Model::Persistence do
339
339
  @course = Course.get r['id']
340
340
  end
341
341
  it "should load the course" do
342
- @course.title.should == "Metaphysics 200"
342
+ expect(@course.title).to eq("Metaphysics 200")
343
343
  end
344
344
  it "should instantiate them as such" do
345
- @course["questions"][0].a[0].should == "beast"
345
+ expect(@course["questions"][0].a[0]).to eq("beast")
346
346
  end
347
347
  end
348
348
 
@@ -354,83 +354,83 @@ describe CouchRest::Model::Persistence do
354
354
 
355
355
  describe "validation" do
356
356
  it "should run before_validation before validating" do
357
- @doc.run_before_validation.should be_nil
358
- @doc.should be_valid
359
- @doc.run_before_validation.should be_true
357
+ expect(@doc.run_before_validation).to be_nil
358
+ expect(@doc).to be_valid
359
+ expect(@doc.run_before_validation).to be_truthy
360
360
  end
361
361
  it "should run after_validation after validating" do
362
- @doc.run_after_validation.should be_nil
363
- @doc.should be_valid
364
- @doc.run_after_validation.should be_true
362
+ expect(@doc.run_after_validation).to be_nil
363
+ expect(@doc).to be_valid
364
+ expect(@doc.run_after_validation).to be_truthy
365
365
  end
366
366
  end
367
367
 
368
368
  describe "with contextual validation on ”create”" do
369
369
  it "should validate only within ”create” context" do
370
370
  doc = WithContextualValidationOnCreate.new
371
- doc.save.should be_false
371
+ expect(doc.save).to be_falsey
372
372
  doc.name = "Alice"
373
- doc.save.should be_true
373
+ expect(doc.save).to be_truthy
374
374
 
375
- doc.update_attributes(:name => nil).should be_true
375
+ expect(doc.update_attributes(:name => nil)).to be_truthy
376
376
  end
377
377
  end
378
378
 
379
379
  describe "with contextual validation on ”update”" do
380
380
  it "should validate only within ”update” context" do
381
381
  doc = WithContextualValidationOnUpdate.new
382
- doc.save.should be_true
382
+ expect(doc.save).to be_truthy
383
383
 
384
- doc.update_attributes(:name => nil).should be_false
385
- doc.update_attributes(:name => "Bob").should be_true
384
+ expect(doc.update_attributes(:name => nil)).to be_falsey
385
+ expect(doc.update_attributes(:name => "Bob")).to be_truthy
386
386
  end
387
387
  end
388
388
 
389
389
  describe "save" do
390
390
  it "should run the after filter after saving" do
391
- @doc.run_after_save.should be_nil
392
- @doc.save.should be_true
393
- @doc.run_after_save.should be_true
391
+ expect(@doc.run_after_save).to be_nil
392
+ expect(@doc.save).to be_truthy
393
+ expect(@doc.run_after_save).to be_truthy
394
394
  end
395
395
  it "should run the grouped callbacks before saving" do
396
- @doc.run_one.should be_nil
397
- @doc.run_two.should be_nil
398
- @doc.run_three.should be_nil
399
- @doc.save.should be_true
400
- @doc.run_one.should be_true
401
- @doc.run_two.should be_true
402
- @doc.run_three.should be_true
396
+ expect(@doc.run_one).to be_nil
397
+ expect(@doc.run_two).to be_nil
398
+ expect(@doc.run_three).to be_nil
399
+ expect(@doc.save).to be_truthy
400
+ expect(@doc.run_one).to be_truthy
401
+ expect(@doc.run_two).to be_truthy
402
+ expect(@doc.run_three).to be_truthy
403
403
  end
404
404
  it "should not run conditional callbacks" do
405
405
  @doc.run_it = false
406
- @doc.save.should be_true
407
- @doc.conditional_one.should be_nil
408
- @doc.conditional_two.should be_nil
406
+ expect(@doc.save).to be_truthy
407
+ expect(@doc.conditional_one).to be_nil
408
+ expect(@doc.conditional_two).to be_nil
409
409
  end
410
410
  it "should run conditional callbacks" do
411
411
  @doc.run_it = true
412
- @doc.save.should be_true
413
- @doc.conditional_one.should be_true
414
- @doc.conditional_two.should be_true
412
+ expect(@doc.save).to be_truthy
413
+ expect(@doc.conditional_one).to be_truthy
414
+ expect(@doc.conditional_two).to be_truthy
415
415
  end
416
416
  end
417
417
  describe "create" do
418
418
  it "should run the before save filter when creating" do
419
- @doc.run_before_save.should be_nil
420
- @doc.create.should_not be_nil
421
- @doc.run_before_save.should be_true
419
+ expect(@doc.run_before_save).to be_nil
420
+ expect(@doc.create).not_to be_nil
421
+ expect(@doc.run_before_save).to be_truthy
422
422
  end
423
423
  it "should run the before create filter" do
424
- @doc.run_before_create.should be_nil
425
- @doc.create.should_not be_nil
424
+ expect(@doc.run_before_create).to be_nil
425
+ expect(@doc.create).not_to be_nil
426
426
  @doc.create
427
- @doc.run_before_create.should be_true
427
+ expect(@doc.run_before_create).to be_truthy
428
428
  end
429
429
  it "should run the after create filter" do
430
- @doc.run_after_create.should be_nil
431
- @doc.create.should_not be_nil
430
+ expect(@doc.run_after_create).to be_nil
431
+ expect(@doc.create).not_to be_nil
432
432
  @doc.create
433
- @doc.run_after_create.should be_true
433
+ expect(@doc.run_after_create).to be_truthy
434
434
  end
435
435
  end
436
436
  describe "update" do
@@ -439,19 +439,19 @@ describe CouchRest::Model::Persistence do
439
439
  @doc.save
440
440
  end
441
441
  it "should run the before update filter when updating an existing document" do
442
- @doc.run_before_update.should be_nil
442
+ expect(@doc.run_before_update).to be_nil
443
443
  @doc.update
444
- @doc.run_before_update.should be_true
444
+ expect(@doc.run_before_update).to be_truthy
445
445
  end
446
446
  it "should run the after update filter when updating an existing document" do
447
- @doc.run_after_update.should be_nil
447
+ expect(@doc.run_after_update).to be_nil
448
448
  @doc.update
449
- @doc.run_after_update.should be_true
449
+ expect(@doc.run_after_update).to be_truthy
450
450
  end
451
451
  it "should run the before update filter when saving an existing document" do
452
- @doc.run_before_update.should be_nil
452
+ expect(@doc.run_before_update).to be_nil
453
453
  @doc.save
454
- @doc.run_before_update.should be_true
454
+ expect(@doc.run_before_update).to be_truthy
455
455
  end
456
456
 
457
457
  end
@@ -461,35 +461,35 @@ describe CouchRest::Model::Persistence do
461
461
  describe "#reload" do
462
462
  it "reloads defined attributes" do
463
463
  i = Article.create!(:title => "Reload when changed")
464
- i.title.should == "Reload when changed"
464
+ expect(i.title).to eq("Reload when changed")
465
465
 
466
466
  i.title = "..."
467
- i.title.should == "..."
467
+ expect(i.title).to eq("...")
468
468
 
469
469
  i.reload
470
- i.title.should == "Reload when changed"
470
+ expect(i.title).to eq("Reload when changed")
471
471
  end
472
472
 
473
473
  it "reloads defined attributes set to nil" do
474
474
  i = Article.create!(:title => "Reload when nil")
475
- i.title.should == "Reload when nil"
475
+ expect(i.title).to eq("Reload when nil")
476
476
 
477
477
  i.title = nil
478
- i.title.should be_nil
478
+ expect(i.title).to be_nil
479
479
 
480
480
  i.reload
481
- i.title.should == "Reload when nil"
481
+ expect(i.title).to eq("Reload when nil")
482
482
  end
483
483
 
484
484
  it "returns self" do
485
485
  i = Article.create!(:title => "Reload return self")
486
- i.reload.should be(i)
486
+ expect(i.reload).to be(i)
487
487
  end
488
488
  end
489
489
 
490
490
  describe ".model_type_value" do
491
491
  it "should always return string value of class" do
492
- Article.model_type_value.should eql('Article')
492
+ expect(Article.model_type_value).to eql('Article')
493
493
  end
494
494
 
495
495
  describe "usage" do
@@ -505,8 +505,8 @@ describe CouchRest::Model::Persistence do
505
505
  obj = klass.build_from_database(
506
506
  '_id' => '1234', 'type' => 'something_else', 'name' => 'Test'
507
507
  )
508
- obj['type'].should eql('something_else')
509
- obj.name.should eql('Test')
508
+ expect(obj['type']).to eql('something_else')
509
+ expect(obj.name).to eql('Test')
510
510
  end
511
511
  it "should fail if different model type value provided" do
512
512
  expect {