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
@@ -9,7 +9,7 @@ describe "Model Base" do
9
9
 
10
10
  describe "instance database connection" do
11
11
  it "should use the default database" do
12
- @obj.database.name.should == 'couchrest-model-test'
12
+ expect(@obj.database.name).to eq('couchrest-model-test')
13
13
  end
14
14
 
15
15
  it "should override the default db" do
@@ -22,52 +22,52 @@ describe "Model Base" do
22
22
  describe "a new model" do
23
23
  it "should be a new document" do
24
24
  @obj = Basic.new
25
- @obj.rev.should be_nil
26
- @obj.should be_new
27
- @obj.should be_new_document
28
- @obj.should be_new_record
25
+ expect(@obj.rev).to be_nil
26
+ expect(@obj).to be_new
27
+ expect(@obj).to be_new_document
28
+ expect(@obj).to be_new_record
29
29
  end
30
30
 
31
31
  it "should not fail with nil argument" do
32
32
  @obj = Basic.new(nil)
33
- @obj.should_not be_nil
33
+ expect(@obj).not_to be_nil
34
34
  end
35
35
 
36
36
  it "should allow the database to be set" do
37
37
  @obj = Basic.new(nil, :database => 'database')
38
- @obj.database.should eql('database')
38
+ expect(@obj.database).to eql('database')
39
39
  end
40
40
 
41
41
  it "should support initialization block" do
42
42
  @obj = Basic.new {|b| b.database = 'database'}
43
- @obj.database.should eql('database')
43
+ expect(@obj.database).to eql('database')
44
44
  end
45
45
 
46
46
  it "should only set defined properties" do
47
47
  @doc = WithDefaultValues.new(:name => 'test', :foo => 'bar')
48
- @doc['name'].should eql('test')
49
- @doc['foo'].should be_nil
48
+ expect(@doc['name']).to eql('test')
49
+ expect(@doc['foo']).to be_nil
50
50
  end
51
51
 
52
- it "should set all properties with :directly_set_attributes option" do
53
- @doc = WithDefaultValues.new({:name => 'test', :foo => 'bar'}, :directly_set_attributes => true)
54
- @doc['name'].should eql('test')
55
- @doc['foo'].should eql('bar')
52
+ it "should set all properties with :write_all_attributes option" do
53
+ @doc = WithDefaultValues.new({:name => 'test', :foo => 'bar'}, :write_all_attributes => true)
54
+ expect(@doc['name']).to eql('test')
55
+ expect(@doc['foo']).to eql('bar')
56
56
  end
57
57
 
58
58
  it "should set the model type" do
59
59
  @doc = WithDefaultValues.new()
60
- @doc[WithDefaultValues.model_type_key].should eql('WithDefaultValues')
60
+ expect(@doc[WithDefaultValues.model_type_key]).to eql('WithDefaultValues')
61
61
  end
62
62
 
63
63
  it "should call after_initialize method if available" do
64
64
  @doc = WithAfterInitializeMethod.new
65
- @doc['some_value'].should eql('value')
65
+ expect(@doc['some_value']).to eql('value')
66
66
  end
67
67
 
68
68
  it "should call after_initialize after block" do
69
69
  @doc = WithAfterInitializeMethod.new {|d| d.some_value = "foo"}
70
- @doc['some_value'].should eql('foo')
70
+ expect(@doc['some_value']).to eql('foo')
71
71
  end
72
72
 
73
73
  it "should call after_initialize callback if available" do
@@ -78,7 +78,7 @@ describe "Model Base" do
78
78
  def set_name; self.name = "foobar"; end
79
79
  end
80
80
  @doc = klass.new
81
- @doc.name.should eql("foobar")
81
+ expect(@doc.name).to eql("foobar")
82
82
  end
83
83
  end
84
84
 
@@ -91,14 +91,14 @@ describe "Model Base" do
91
91
  describe "#to_key" do
92
92
  context "when the document is new" do
93
93
  it "returns nil" do
94
- @obj.to_key.should be_nil
94
+ expect(@obj.to_key).to be_nil
95
95
  end
96
96
  end
97
97
 
98
98
  context "when the document is not new" do
99
99
  it "returns id in an array" do
100
100
  @obj.save
101
- @obj.to_key.should eql([@obj['_id']])
101
+ expect(@obj.to_key).to eql([@obj['_id']])
102
102
  end
103
103
  end
104
104
  end
@@ -106,14 +106,14 @@ describe "Model Base" do
106
106
  describe "#to_param" do
107
107
  context "when the document is new" do
108
108
  it "returns nil" do
109
- @obj.to_param.should be_nil
109
+ expect(@obj.to_param).to be_nil
110
110
  end
111
111
  end
112
112
 
113
113
  context "when the document is not new" do
114
114
  it "returns id" do
115
115
  @obj.save
116
- @obj.to_param.should eql(@obj['_id'])
116
+ expect(@obj.to_param).to eql(@obj['_id'])
117
117
  end
118
118
  end
119
119
  end
@@ -121,14 +121,14 @@ describe "Model Base" do
121
121
  describe "#persisted?" do
122
122
  context "when the document is new" do
123
123
  it "returns false" do
124
- @obj.persisted?.should be_false
124
+ expect(@obj.persisted?).to be_falsey
125
125
  end
126
126
  end
127
127
 
128
128
  context "when the document is not new" do
129
129
  it "returns id" do
130
130
  @obj.save
131
- @obj.persisted?.should be_true
131
+ expect(@obj.persisted?).to be_truthy
132
132
  end
133
133
  end
134
134
 
@@ -136,29 +136,29 @@ describe "Model Base" do
136
136
  it "returns false" do
137
137
  @obj.save
138
138
  @obj.destroy
139
- @obj.persisted?.should be_false
139
+ expect(@obj.persisted?).to be_falsey
140
140
  end
141
141
  end
142
142
  end
143
143
 
144
144
  describe "#model_name" do
145
145
  it "returns the name of the model" do
146
- @obj.class.model_name.should eql('Basic')
147
- WithDefaultValues.model_name.human.should eql("With default values")
146
+ expect(@obj.class.model_name).to eql('Basic')
147
+ expect(WithDefaultValues.model_name.human).to eql("With default values")
148
148
  end
149
149
  end
150
150
 
151
151
  describe "#destroyed?" do
152
152
  it "should be present" do
153
- @obj.should respond_to(:destroyed?)
153
+ expect(@obj).to respond_to(:destroyed?)
154
154
  end
155
155
  it "should return false with new object" do
156
- @obj.destroyed?.should be_false
156
+ expect(@obj.destroyed?).to be_falsey
157
157
  end
158
158
  it "should return true after destroy" do
159
159
  @obj.save
160
160
  @obj.destroy
161
- @obj.destroyed?.should be_true
161
+ expect(@obj.destroyed?).to be_truthy
162
162
  end
163
163
  end
164
164
  end
@@ -168,34 +168,34 @@ describe "Model Base" do
168
168
  context "on saved document" do
169
169
  it "should be true on same document" do
170
170
  p = Project.create
171
- p.should eql(p)
171
+ expect(p).to eql(p)
172
172
  end
173
173
  it "should be true after loading" do
174
174
  p = Project.create
175
- p.should eql(Project.get(p.id))
175
+ expect(p).to eql(Project.get(p.id))
176
176
  end
177
177
  it "should not be true if databases do not match" do
178
178
  p = Project.create
179
179
  p2 = p.dup
180
- p2.stub(:database).and_return('other')
181
- p.should_not eql(p2)
180
+ allow(p2).to receive(:database).and_return('other')
181
+ expect(p).not_to eql(p2)
182
182
  end
183
183
  it "should always be false if one document not saved" do
184
184
  p = Project.create(:name => 'test')
185
185
  o = Project.new(:name => 'test')
186
- p.should_not eql(o)
186
+ expect(p).not_to eql(o)
187
187
  end
188
188
  end
189
189
  context "with new documents" do
190
190
  it "should be true when attributes match" do
191
191
  p = Project.new(:name => 'test')
192
192
  o = Project.new(:name => 'test')
193
- p.should eql(o)
193
+ expect(p).to eql(o)
194
194
  end
195
195
  it "should not be true when attributes don't match" do
196
196
  p = Project.new(:name => 'test')
197
197
  o = Project.new(:name => 'testing')
198
- p.should_not eql(o)
198
+ expect(p).not_to eql(o)
199
199
  end
200
200
  end
201
201
  end
@@ -209,37 +209,37 @@ describe "Model Base" do
209
209
  @art.save
210
210
  end
211
211
  it "should work for attribute= methods" do
212
- @art['title'].should == "big bad danger"
213
- @art.update_attributes_without_saving('date' => Time.now, :title => "super danger")
214
- @art['title'].should == "super danger"
212
+ expect(@art['title']).to eql("big bad danger")
213
+ @art.write_attributes('date' => Time.now, :title => "super danger")
214
+ expect(@art['title']).to eql("super danger")
215
215
  end
216
216
  it "should silently ignore _id" do
217
- @art.update_attributes_without_saving('_id' => 'foobar')
218
- @art['_id'].should_not == 'foobar'
217
+ @art.write_attributes('_id' => 'foobar')
218
+ expect(@art['_id']).to_not eql('foobar')
219
219
  end
220
220
  it "should silently ignore _rev" do
221
- @art.update_attributes_without_saving('_rev' => 'foobar')
222
- @art['_rev'].should_not == 'foobar'
221
+ @art.write_attributes('_rev' => 'foobar')
222
+ expect(@art['_rev']).to_not eql('foobar')
223
223
  end
224
224
  it "should silently ignore created_at" do
225
- @art.update_attributes_without_saving('created_at' => 'foobar')
225
+ @art.write_attributes('created_at' => 'foobar')
226
226
  expect(@art['created_at'].to_s).to_not eql('foobar')
227
227
  end
228
228
  it "should silently ignore updated_at" do
229
- @art.update_attributes_without_saving('updated_at' => 'foobar')
229
+ @art.write_attributes('updated_at' => 'foobar')
230
230
  expect(@art['updated_at']).to_not eql('foobar')
231
231
  end
232
232
  it "should also work using attributes= alias" do
233
- @art.respond_to?(:attributes=).should be_true
233
+ expect(@art.respond_to?(:attributes=)).to be_truthy
234
234
  @art.attributes = {'date' => Time.now, :title => "something else"}
235
- @art['title'].should == "something else"
235
+ expect(@art['title']).to eql("something else")
236
236
  end
237
237
 
238
238
  it "should not flip out if an attribute= method is missing and ignore it" do
239
- lambda {
240
- @art.update_attributes_without_saving('slug' => "new-slug", :title => "super danger")
241
- }.should_not raise_error
242
- @art.slug.should == "big-bad-danger"
239
+ expect {
240
+ @art.attributes = {'slug' => "new-slug", :title => "super danger"}
241
+ }.not_to raise_error
242
+ expect(@art.slug).to eq("big-bad-danger")
243
243
  end
244
244
 
245
245
  #it "should not change other attributes if there is an error" do
@@ -258,25 +258,25 @@ describe "Model Base" do
258
258
  @art.save
259
259
  end
260
260
  it "should save" do
261
- @art['title'].should == "big bad danger"
261
+ expect(@art['title']).to eq("big bad danger")
262
262
  @art.update_attributes('date' => Time.now, :title => "super danger")
263
263
  loaded = Article.get(@art.id)
264
- loaded['title'].should == "super danger"
264
+ expect(loaded['title']).to eq("super danger")
265
265
  end
266
266
  end
267
267
 
268
268
  describe "with default" do
269
269
  it "should have the default value set at initalization" do
270
- @obj.preset.should == {:right => 10, :top_align => false}
270
+ expect(@obj.preset).to eq({:right => 10, :top_align => false})
271
271
  end
272
272
 
273
273
  it "should have the default false value explicitly assigned" do
274
- @obj.default_false.should == false
274
+ expect(@obj.default_false).to eq(false)
275
275
  end
276
276
 
277
277
  it "should automatically call a proc default at initialization" do
278
- @obj.set_by_proc.should be_an_instance_of(Time)
279
- @obj.set_by_proc.should == @obj.set_by_proc
278
+ expect(@obj.set_by_proc).to be_an_instance_of(Time)
279
+ expect(@obj.set_by_proc).to eq(@obj.set_by_proc)
280
280
  expect(@obj.set_by_proc.utc).to be < Time.now.utc
281
281
  end
282
282
 
@@ -288,31 +288,31 @@ describe "Model Base" do
288
288
  it "should keep default values for new instances" do
289
289
  obj = WithDefaultValues.new
290
290
  obj.preset[:alpha] = 123
291
- obj.preset.should == {:right => 10, :top_align => false, :alpha => 123}
291
+ expect(obj.preset).to eq({:right => 10, :top_align => false, :alpha => 123})
292
292
  another = WithDefaultValues.new
293
- another.preset.should == {:right => 10, :top_align => false}
293
+ expect(another.preset).to eq({:right => 10, :top_align => false})
294
294
  end
295
295
 
296
296
  it "should work with a default empty array" do
297
297
  obj = WithDefaultValues.new(:tags => ['spec'])
298
- obj.tags.should == ['spec']
298
+ expect(obj.tags).to eq(['spec'])
299
299
  end
300
300
 
301
301
  it "should set default value of read-only property" do
302
302
  obj = WithDefaultValues.new
303
- obj.read_only_with_default.should == 'generic'
303
+ expect(obj.read_only_with_default).to eq('generic')
304
304
  end
305
305
  end
306
306
 
307
307
  describe "simplified way of setting property types" do
308
308
  it "should set defaults" do
309
309
  obj = WithSimplePropertyType.new
310
- obj.preset.should eql('none')
310
+ expect(obj.preset).to eql('none')
311
311
  end
312
312
 
313
313
  it "should handle arrays" do
314
314
  obj = WithSimplePropertyType.new(:tags => ['spec'])
315
- obj.tags.should == ['spec']
315
+ expect(obj.tags).to eq(['spec'])
316
316
  end
317
317
  end
318
318
 
@@ -324,16 +324,16 @@ describe "Model Base" do
324
324
  @tmpl2 = WithTemplateAndUniqueID.new(:preset => 'not_value', 'slug' => '1')
325
325
  end
326
326
  it "should have fields set when new" do
327
- @tmpl.preset.should == 'value'
327
+ expect(@tmpl.preset).to eq('value')
328
328
  end
329
329
  it "shouldn't override explicitly set values" do
330
- @tmpl2.preset.should == 'not_value'
330
+ expect(@tmpl2.preset).to eq('not_value')
331
331
  end
332
332
  it "shouldn't override existing documents" do
333
333
  @tmpl2.save
334
334
  tmpl2_reloaded = WithTemplateAndUniqueID.get(@tmpl2.id)
335
- @tmpl2.preset.should == 'not_value'
336
- tmpl2_reloaded.preset.should == 'not_value'
335
+ expect(@tmpl2.preset).to eq('not_value')
336
+ expect(tmpl2_reloaded.preset).to eq('not_value')
337
337
  end
338
338
  end
339
339
 
@@ -349,7 +349,7 @@ describe "Model Base" do
349
349
  end
350
350
  it "should find all" do
351
351
  rs = WithTemplateAndUniqueID.all
352
- rs.length.should == 4
352
+ expect(rs.length).to eq(4)
353
353
  end
354
354
  end
355
355
 
@@ -359,14 +359,14 @@ describe "Model Base" do
359
359
  end
360
360
 
361
361
  it ".count should return 0 if there are no docuemtns" do
362
- WithTemplateAndUniqueID.count.should == 0
362
+ expect(WithTemplateAndUniqueID.count).to eq(0)
363
363
  end
364
364
 
365
365
  it ".count should return the number of documents" do
366
366
  WithTemplateAndUniqueID.new('slug' => '1').save
367
367
  WithTemplateAndUniqueID.new('slug' => '2').save
368
368
  WithTemplateAndUniqueID.new('slug' => '3').save
369
- WithTemplateAndUniqueID.count.should == 3
369
+ expect(WithTemplateAndUniqueID.count).to eq(3)
370
370
  end
371
371
  end
372
372
 
@@ -380,11 +380,11 @@ describe "Model Base" do
380
380
  end
381
381
  it "should find first" do
382
382
  rs = WithTemplateAndUniqueID.first
383
- rs['slug'].should == "1"
383
+ expect(rs['slug']).to eq("1")
384
384
  end
385
385
  it "should return nil if no instances are found" do
386
386
  WithTemplateAndUniqueID.all.each {|obj| obj.destroy }
387
- WithTemplateAndUniqueID.first.should be_nil
387
+ expect(WithTemplateAndUniqueID.first).to be_nil
388
388
  end
389
389
  end
390
390
 
@@ -402,13 +402,13 @@ describe "Model Base" do
402
402
  @course = Course.get r['id']
403
403
  end
404
404
  it "should load the course" do
405
- @course["professor"]["name"][1].should == "Hinchliff"
405
+ expect(@course["professor"]["name"][1]).to eq("Hinchliff")
406
406
  end
407
407
  it "should instantiate the professor as a person" do
408
- @course['professor'].last_name.should == "Hinchliff"
408
+ expect(@course['professor'].last_name).to eq("Hinchliff")
409
409
  end
410
410
  it "should instantiate the ends_at as a Time" do
411
- @course['ends_at'].should == Time.parse("2008/12/19 13:00:00 +0800")
411
+ expect(@course['ends_at']).to eq(Time.parse("2008/12/19 13:00:00 +0800"))
412
412
  end
413
413
  end
414
414
 
@@ -424,39 +424,39 @@ describe "Model Base" do
424
424
  @obj.save
425
425
  json = @obj.to_json
426
426
  obj = WithDefaultValues.get(@obj.id)
427
- obj.should be_an_instance_of(WithDefaultValues)
428
- obj.created_at.should be_an_instance_of(Time)
429
- obj.updated_at.should be_an_instance_of(Time)
430
- obj.created_at.to_s.should == @obj.updated_at.to_s
427
+ expect(obj).to be_an_instance_of(WithDefaultValues)
428
+ expect(obj.created_at).to be_an_instance_of(Time)
429
+ expect(obj.updated_at).to be_an_instance_of(Time)
430
+ expect(obj.created_at.to_s).to eq(@obj.updated_at.to_s)
431
431
  end
432
432
 
433
433
  it "should not change created_at on update" do
434
434
  2.times do
435
- lambda do
435
+ expect do
436
436
  @art.save
437
- end.should_not change(@art, :created_at)
437
+ end.not_to change(@art, :created_at)
438
438
  end
439
439
  end
440
440
 
441
441
  it "should set the time on create" do
442
- (Time.now - @art.created_at).should < 2
442
+ expect(Time.now - @art.created_at).to be < 2
443
443
  foundart = Article.get @art.id
444
444
  # Use string for comparison to cope with microsecond differences
445
- foundart.created_at.to_s.should == foundart.updated_at.to_s
445
+ expect(foundart.created_at.to_s).to eq(foundart.updated_at.to_s)
446
446
  end
447
447
  it "should set the time on update" do
448
448
  @art.title = "new title" # only saved if @art.changed? == true
449
449
  @art.save
450
- @art.created_at.should < @art.updated_at
450
+ expect(@art.created_at).to be < @art.updated_at
451
451
  end
452
452
  end
453
453
 
454
454
  describe "getter and setter methods" do
455
455
  it "should try to call the arg= method before setting :arg in the hash" do
456
456
  @doc = WithGetterAndSetterMethods.new(:arg => "foo")
457
- @doc['arg'].should be_nil
458
- @doc[:arg].should be_nil
459
- @doc.other_arg.should == "foo-foo"
457
+ expect(@doc['arg']).to be_nil
458
+ expect(@doc[:arg]).to be_nil
459
+ expect(@doc.other_arg).to eq("foo-foo")
460
460
  end
461
461
  end
462
462
 
@@ -468,30 +468,30 @@ describe "Model Base" do
468
468
 
469
469
  it "should not save if a nested casted model is invalid" do
470
470
  @cat.favorite_toy = CatToy.new
471
- @cat.should_not be_valid
472
- @cat.save.should be_false
473
- lambda{@cat.save!}.should raise_error
471
+ expect(@cat).not_to be_valid
472
+ expect(@cat.save).to be_falsey
473
+ expect{@cat.save!}.to raise_error(/Validation Failed/)
474
474
  end
475
475
 
476
476
  it "should save when nested casted model is valid" do
477
477
  @cat.favorite_toy = CatToy.new(:name => 'Squeaky')
478
- @cat.should be_valid
479
- @cat.save.should be_true
480
- lambda{@cat.save!}.should_not raise_error
478
+ expect(@cat).to be_valid
479
+ expect(@cat.save).to be_truthy
480
+ expect{@cat.save!}.not_to raise_error
481
481
  end
482
482
 
483
483
  it "should not save when nested collection contains an invalid casted model" do
484
484
  @cat.toys = [CatToy.new(:name => 'Feather'), CatToy.new]
485
- @cat.should_not be_valid
486
- @cat.save.should be_false
487
- lambda{@cat.save!}.should raise_error
485
+ expect(@cat).not_to be_valid
486
+ expect(@cat.save).to be_falsey
487
+ expect{@cat.save!}.to raise_error(/Validation Failed/)
488
488
  end
489
489
 
490
490
  it "should save when nested collection contains valid casted models" do
491
491
  @cat.toys = [CatToy.new(:name => 'feather'), CatToy.new(:name => 'ball-o-twine')]
492
- @cat.should be_valid
493
- @cat.save.should be_true
494
- lambda{@cat.save!}.should_not raise_error
492
+ expect(@cat).to be_valid
493
+ expect(@cat.save).to be_truthy
494
+ expect{@cat.save!}.not_to raise_error
495
495
  end
496
496
 
497
497
  it "should not fail if the nested casted model doesn't have validation" do
@@ -499,8 +499,8 @@ describe "Model Base" do
499
499
  Cat.validates_presence_of :name
500
500
  cat = Cat.new(:name => 'Mr Bigglesworth')
501
501
  cat.trainer = Person.new
502
- cat.should be_valid
503
- cat.save.should be_true
502
+ expect(cat).to be_valid
503
+ expect(cat.save).to be_truthy
504
504
  end
505
505
  end
506
506