couch_potato 1.4.0 → 1.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -0
  3. data/.travis.yml +12 -8
  4. data/CHANGES.md +4 -0
  5. data/Gemfile +1 -1
  6. data/README.md +396 -276
  7. data/Rakefile +9 -9
  8. data/couch_potato-rspec.gemspec +20 -0
  9. data/couch_potato.gemspec +15 -16
  10. data/{active_support_4_0 → gemfiles/active_support_4_0} +3 -3
  11. data/{active_support_3_2 → gemfiles/active_support_4_1} +3 -2
  12. data/gemfiles/active_support_4_2 +11 -0
  13. data/lib/couch_potato-rspec.rb +3 -0
  14. data/lib/couch_potato.rb +3 -1
  15. data/lib/couch_potato/database.rb +42 -39
  16. data/lib/couch_potato/persistence/magic_timestamps.rb +5 -5
  17. data/lib/couch_potato/persistence/properties.rb +8 -2
  18. data/lib/couch_potato/persistence/simple_property.rb +11 -9
  19. data/lib/couch_potato/persistence/type_caster.rb +1 -1
  20. data/lib/couch_potato/railtie.rb +2 -0
  21. data/lib/couch_potato/version.rb +2 -1
  22. data/lib/couch_potato/view/base_view_spec.rb +18 -8
  23. data/lib/couch_potato/view/view_query.rb +2 -3
  24. data/spec/attachments_spec.rb +3 -3
  25. data/spec/callbacks_spec.rb +193 -113
  26. data/spec/conflict_handling_spec.rb +4 -4
  27. data/spec/create_spec.rb +5 -5
  28. data/spec/default_property_spec.rb +6 -6
  29. data/spec/destroy_spec.rb +5 -5
  30. data/spec/property_spec.rb +71 -61
  31. data/spec/rails_spec.rb +3 -3
  32. data/spec/railtie_spec.rb +12 -13
  33. data/spec/spec_helper.rb +3 -3
  34. data/spec/unit/active_model_compliance_spec.rb +16 -16
  35. data/spec/unit/attributes_spec.rb +36 -34
  36. data/spec/unit/base_view_spec_spec.rb +82 -35
  37. data/spec/unit/callbacks_spec.rb +2 -2
  38. data/spec/unit/couch_potato_spec.rb +3 -3
  39. data/spec/unit/create_spec.rb +12 -12
  40. data/spec/unit/custom_views_spec.rb +1 -1
  41. data/spec/unit/database_spec.rb +95 -95
  42. data/spec/unit/date_spec.rb +3 -3
  43. data/spec/unit/deep_dirty_attributes_spec.rb +104 -104
  44. data/spec/unit/dirty_attributes_spec.rb +19 -19
  45. data/spec/unit/forbidden_attributes_protection_spec.rb +4 -4
  46. data/spec/unit/initialize_spec.rb +37 -19
  47. data/spec/unit/json_spec.rb +4 -4
  48. data/spec/unit/lists_spec.rb +8 -8
  49. data/spec/unit/model_view_spec_spec.rb +14 -14
  50. data/spec/unit/persistence_spec.rb +6 -6
  51. data/spec/unit/properties_view_spec_spec.rb +4 -4
  52. data/spec/unit/rspec_matchers_spec.rb +73 -73
  53. data/spec/unit/rspec_stub_db_spec.rb +43 -42
  54. data/spec/unit/string_spec.rb +1 -1
  55. data/spec/unit/time_spec.rb +2 -2
  56. data/spec/unit/validation_spec.rb +1 -1
  57. data/spec/unit/view_query_spec.rb +54 -59
  58. data/spec/update_spec.rb +5 -5
  59. data/spec/view_updates_spec.rb +4 -4
  60. data/spec/views_spec.rb +43 -43
  61. metadata +18 -22
  62. data/lib/couch_potato/rspec.rb +0 -2
  63. data/lib/couch_potato/rspec/matchers.rb +0 -56
  64. data/lib/couch_potato/rspec/matchers/json2.js +0 -482
  65. data/lib/couch_potato/rspec/matchers/list_as_matcher.rb +0 -53
  66. data/lib/couch_potato/rspec/matchers/map_reduce_to_matcher.rb +0 -166
  67. data/lib/couch_potato/rspec/matchers/map_to_matcher.rb +0 -61
  68. data/lib/couch_potato/rspec/matchers/reduce_to_matcher.rb +0 -48
  69. data/lib/couch_potato/rspec/stub_db.rb +0 -57
@@ -3,20 +3,20 @@ require 'spec_helper'
3
3
  describe Date, 'to_json' do
4
4
  it "should format the date in a way that i can use it for sorting in couchdb" do
5
5
  date = Date.parse('2009-01-01')
6
- date.to_json.should == "\"2009/01/01\""
6
+ expect(date.to_json).to eq("\"2009/01/01\"")
7
7
  end
8
8
  end
9
9
 
10
10
  describe Date, 'as_json' do
11
11
  it "should format it in the same way as to_json does so i can use this to do queries over date attributes" do
12
12
  date = Date.parse('2009-01-01')
13
- date.as_json.should == "2009/01/01"
13
+ expect(date.as_json).to eq("2009/01/01")
14
14
  end
15
15
  end
16
16
 
17
17
  describe Date, 'to_s' do
18
18
  it "should leave the original to_s untouched" do
19
19
  date = Date.parse('2009-01-01')
20
- date.to_s.should == "2009-01-01"
20
+ expect(date.to_s).to eq("2009-01-01")
21
21
  end
22
22
  end
@@ -43,8 +43,8 @@ describe "deep dirty attribute tracking" do
43
43
  it "should return true if only root simple properties have changed" do
44
44
  book = Book.new(:title => "A")
45
45
  book.title = "B"
46
- book.should be_title_changed
47
- book.should be_changed
46
+ expect(book).to be_title_changed
47
+ expect(book).to be_changed
48
48
  end
49
49
  end
50
50
 
@@ -52,8 +52,8 @@ describe "deep dirty attribute tracking" do
52
52
  it "gives access to old values of simple root properties" do
53
53
  book = Book.new(:title => "A")
54
54
  book.title = "B"
55
- book.title_was.should == "A"
56
- book.title_change.should == ["A", "B"]
55
+ expect(book.title_was).to eq("A")
56
+ expect(book.title_change).to eq(["A", "B"])
57
57
  end
58
58
  end
59
59
 
@@ -61,7 +61,7 @@ describe "deep dirty attribute tracking" do
61
61
  it "returns standard _change" do
62
62
  book = Book.new(:title => "A")
63
63
  book.title = "B"
64
- book.title_change.should == ["A", "B"]
64
+ expect(book.title_change).to eq(["A", "B"])
65
65
  end
66
66
  end
67
67
  end
@@ -71,35 +71,35 @@ describe "deep dirty attribute tracking" do
71
71
  it "should return true if a nested attribute has changed" do
72
72
  book = Book.new(:cover => Cover.new(:color => "red"))
73
73
  book.cover.color = "blue"
74
- book.should be_cover_changed
75
- book.should be_changed
74
+ expect(book).to be_cover_changed
75
+ expect(book).to be_changed
76
76
  end
77
77
 
78
78
  it "should return true if changed to a different document" do
79
79
  book = Book.new(:cover => Cover.new(:color => "red"))
80
80
  book.cover = Cover.new(:color => "blue")
81
- book.should be_cover_changed
82
- book.should be_changed
81
+ expect(book).to be_cover_changed
82
+ expect(book).to be_changed
83
83
  end
84
84
 
85
85
  it "should return false if changed to a clone of the original document" do
86
86
  book = Book.new(:cover => Cover.new(:color => "red"))
87
87
  book.cover = book.cover.clone
88
- book.should_not be_cover_changed
89
- book.should_not be_changed
88
+ expect(book).not_to be_cover_changed
89
+ expect(book).not_to be_changed
90
90
  end
91
91
 
92
92
  it "should return false if set to nil and unchanged" do
93
93
  book = Book.new
94
- book.should_not be_cover_changed
95
- book.should_not be_changed
94
+ expect(book).not_to be_cover_changed
95
+ expect(book).not_to be_changed
96
96
  end
97
97
 
98
98
  it "should return true when reassigned with changes but the same _id" do
99
99
  book = Book.new(:cover => Cover.new(:_id => "cid", :color => "red"))
100
100
  book.cover = Cover.new(:_id => "cid", :color => "blue")
101
- book.should be_cover_changed
102
- book.should be_changed
101
+ expect(book).to be_cover_changed
102
+ expect(book).to be_changed
103
103
  end
104
104
  end
105
105
 
@@ -107,7 +107,7 @@ describe "deep dirty attribute tracking" do
107
107
  it "gives access to the old value" do
108
108
  book = Book.new(:cover => Cover.new(:color => "red"))
109
109
  book.cover.color = "blue"
110
- book.cover_was.color.should == "red"
110
+ expect(book.cover_was.color).to eq("red")
111
111
  end
112
112
  end
113
113
 
@@ -115,41 +115,41 @@ describe "deep dirty attribute tracking" do
115
115
  it "should return the standard changes when a nested document is reassigned" do
116
116
  book = Book.new(:cover => Cover.new(:color => "red"))
117
117
  book.cover = Cover.new(:color => "blue")
118
- book.cover_change[0].should be_a Cover
119
- book.cover_change[0].color.should == "red"
120
- book.cover_change[1].should be_a Cover
121
- book.cover_change[1].color.should == "blue"
118
+ expect(book.cover_change[0]).to be_a Cover
119
+ expect(book.cover_change[0].color).to eq("red")
120
+ expect(book.cover_change[1]).to be_a Cover
121
+ expect(book.cover_change[1].color).to eq("blue")
122
122
  end
123
123
 
124
124
  it "should return the standard changes when a nested document is reassigned from nil" do
125
125
  book = Book.new
126
126
  book.cover = Cover.new
127
- book.cover_change[0].should == nil
128
- book.cover_change[1].should == book.cover
127
+ expect(book.cover_change[0]).to eq(nil)
128
+ expect(book.cover_change[1]).to eq(book.cover)
129
129
  end
130
130
 
131
131
  it "should return the standard changes when a nested document is reassigned to nil" do
132
132
  cover = Cover.new
133
133
  book = Book.new(:cover => cover)
134
134
  book.cover = nil
135
- book.cover_change[0].should == cover
136
- book.cover_change[1].should == nil
135
+ expect(book.cover_change[0]).to eq(cover)
136
+ expect(book.cover_change[1]).to eq(nil)
137
137
  end
138
138
 
139
139
  it "should return the nested changes when a nested document is changed" do
140
140
  book = Book.new(:cover => Cover.new(:color => "red"))
141
141
  book.cover.color = "blue"
142
- book.cover_change[0].should be_a Cover
143
- book.cover_change[0].color.should == "red"
144
- book.cover_change[1].should == book.cover.changes
142
+ expect(book.cover_change[0]).to be_a Cover
143
+ expect(book.cover_change[0].color).to eq("red")
144
+ expect(book.cover_change[1]).to eq(book.cover.changes)
145
145
  end
146
146
 
147
147
  it "should return the nested changes when reassigned with changes but the same _id" do
148
148
  book = Book.new(:cover => Cover.new(:_id => "cid", :color => "red"))
149
149
  book.cover = Cover.new(:_id => "cid", :color => "blue")
150
- book.cover_change[0].should be_a Cover
151
- book.cover_change[0].color.should == "red"
152
- book.cover_change[1].should == {"color" => ["red", "blue"]}
150
+ expect(book.cover_change[0]).to be_a Cover
151
+ expect(book.cover_change[0].color).to eq("red")
152
+ expect(book.cover_change[1]).to eq({"color" => ["red", "blue"]})
153
153
  end
154
154
  end
155
155
  end
@@ -159,28 +159,28 @@ describe "deep dirty attribute tracking" do
159
159
  it "returns true if the array is reassigned" do
160
160
  book = Book.new(:authors => ["Sarah"])
161
161
  book.authors = ["Jane"]
162
- book.should be_authors_changed
162
+ expect(book).to be_authors_changed
163
163
  end
164
164
 
165
165
  it "returns true if an item is added" do
166
166
  book = Book.new(:authors => ["Jane"])
167
167
  book.authors << "Sue"
168
- book.should be_authors_changed
169
- book.should be_changed
168
+ expect(book).to be_authors_changed
169
+ expect(book).to be_changed
170
170
  end
171
171
 
172
172
  it "returns true if an item is removed" do
173
173
  book = Book.new(:authors => ["Sue"])
174
174
  book.authors.delete "Sue"
175
- book.should be_authors_changed
176
- book.should be_changed
175
+ expect(book).to be_authors_changed
176
+ expect(book).to be_changed
177
177
  end
178
178
 
179
179
  it "returns false if an empty array is unchanged" do
180
180
  book = Book.new(:authors => [])
181
181
  book.authors = []
182
- book.should_not be_authors_changed
183
- book.should_not be_changed
182
+ expect(book).not_to be_authors_changed
183
+ expect(book).not_to be_changed
184
184
  end
185
185
  end
186
186
 
@@ -188,7 +188,7 @@ describe "deep dirty attribute tracking" do
188
188
  it "gives access to the old values" do
189
189
  book = Book.new(:authors => ["Jane"])
190
190
  book.authors << "Sue"
191
- book.authors_was.should == ["Jane"]
191
+ expect(book.authors_was).to eq(["Jane"])
192
192
  end
193
193
  end
194
194
 
@@ -197,37 +197,37 @@ describe "deep dirty attribute tracking" do
197
197
  book = Book.new(:authors => ["Jane"])
198
198
  book.authors << "Sue"
199
199
  book.authors.delete "Jane"
200
- book.authors_change[0].should == ["Jane"]
201
- book.authors_change[1].should be_a HashWithIndifferentAccess
202
- book.authors_change[1][:added].should == ["Sue"]
203
- book.authors_change[1][:removed].should == ["Jane"]
200
+ expect(book.authors_change[0]).to eq(["Jane"])
201
+ expect(book.authors_change[1]).to be_a HashWithIndifferentAccess
202
+ expect(book.authors_change[1][:added]).to eq(["Sue"])
203
+ expect(book.authors_change[1][:removed]).to eq(["Jane"])
204
204
  end
205
205
 
206
206
  it "returns a hash of added and removed items when the array is reassigned" do
207
207
  book = Book.new(:authors => ["Jane"])
208
208
  book.authors = ["Sue"]
209
- book.authors_change[0].should == ["Jane"]
210
- book.authors_change[1].should be_a HashWithIndifferentAccess
211
- book.authors_change[1][:added].should == ["Sue"]
212
- book.authors_change[1][:removed].should == ["Jane"]
209
+ expect(book.authors_change[0]).to eq(["Jane"])
210
+ expect(book.authors_change[1]).to be_a HashWithIndifferentAccess
211
+ expect(book.authors_change[1][:added]).to eq(["Sue"])
212
+ expect(book.authors_change[1][:removed]).to eq(["Jane"])
213
213
  end
214
214
 
215
215
  it "returns a hash of added items when the value is changed from nil to an array" do
216
216
  book = Book.new
217
217
  book.authors = ["Sue"]
218
- book.authors_change[0].should == []
219
- book.authors_change[1].should be_a HashWithIndifferentAccess
220
- book.authors_change[1][:added].should == ["Sue"]
221
- book.authors_change[1][:removed].should == []
218
+ expect(book.authors_change[0]).to eq([])
219
+ expect(book.authors_change[1]).to be_a HashWithIndifferentAccess
220
+ expect(book.authors_change[1][:added]).to eq(["Sue"])
221
+ expect(book.authors_change[1][:removed]).to eq([])
222
222
  end
223
223
 
224
224
  it "returns a hash of removed items when the value is changed from an array to nil" do
225
225
  book = Book.new(:authors => ["Jane"])
226
226
  book.authors = nil
227
- book.authors_change[0].should == ["Jane"]
228
- book.authors_change[1].should be_a HashWithIndifferentAccess
229
- book.authors_change[1][:added].should == []
230
- book.authors_change[1][:removed].should == ["Jane"]
227
+ expect(book.authors_change[0]).to eq(["Jane"])
228
+ expect(book.authors_change[1]).to be_a HashWithIndifferentAccess
229
+ expect(book.authors_change[1][:added]).to eq([])
230
+ expect(book.authors_change[1][:removed]).to eq(["Jane"])
231
231
  end
232
232
  end
233
233
  end
@@ -237,50 +237,50 @@ describe "deep dirty attribute tracking" do
237
237
  it "returns true if an item is changed" do
238
238
  book = Book.new(:pages => [Page.new(:number => 1)])
239
239
  book.pages[0].number = 2
240
- book.should be_pages_changed
241
- book.should be_changed
240
+ expect(book).to be_pages_changed
241
+ expect(book).to be_changed
242
242
  end
243
243
 
244
244
  it "returns true if an item is added" do
245
245
  book = Book.new(:pages => [Page.new(:number => 1)])
246
246
  book.pages << Page.new(:number => 2)
247
- book.should be_pages_changed
248
- book.should be_changed
247
+ expect(book).to be_pages_changed
248
+ expect(book).to be_changed
249
249
  end
250
250
 
251
251
  it "returns true if an items is removed" do
252
252
  book = Book.new(:pages => [Page.new(:number => 1)])
253
253
  book.pages.delete_at 0
254
- book.should be_pages_changed
255
- book.should be_changed
254
+ expect(book).to be_pages_changed
255
+ expect(book).to be_changed
256
256
  end
257
257
 
258
258
  it "returns true if an item is replaced" do
259
259
  book = Book.new(:pages => [Page.new(:number => 1)])
260
260
  book.pages[0] = Page.new(:number => 2)
261
- book.should be_pages_changed
262
- book.should be_changed
261
+ expect(book).to be_pages_changed
262
+ expect(book).to be_changed
263
263
  end
264
264
 
265
265
  it "returns false if an item is replaced with a clone" do
266
266
  book = Book.new(:pages => [Page.new(:number => 1)])
267
267
  book.pages[0] = book.pages[0].clone
268
- book.should_not be_pages_changed
269
- book.should_not be_changed
268
+ expect(book).not_to be_pages_changed
269
+ expect(book).not_to be_changed
270
270
  end
271
271
 
272
272
  it "returns true if an item is replaced with changes but the same _id" do
273
273
  book = Book.new(:pages => [Page.new(:_id => "pid", :number => 1)])
274
274
  book.pages[0] = Page.new(:_id => "pid", :number => 2)
275
- book.should be_pages_changed
276
- book.should be_changed
275
+ expect(book).to be_pages_changed
276
+ expect(book).to be_changed
277
277
  end
278
278
 
279
279
  it "returns false if an empty array is unchanged" do
280
280
  book = Book.new(:pages => [])
281
281
  book.pages = []
282
- book.should_not be_authors_changed
283
- book.should_not be_changed
282
+ expect(book).not_to be_authors_changed
283
+ expect(book).not_to be_changed
284
284
  end
285
285
  end
286
286
 
@@ -288,7 +288,7 @@ describe "deep dirty attribute tracking" do
288
288
  it "gives access to the old values" do
289
289
  book = Book.new(:pages => [Page.new(:number => 1)])
290
290
  book.pages[0].number = 2
291
- book.pages_was[0].number.should == 1
291
+ expect(book.pages_was[0].number).to eq(1)
292
292
  end
293
293
  end
294
294
 
@@ -302,13 +302,13 @@ describe "deep dirty attribute tracking" do
302
302
  book.pages = [p2]
303
303
  p2.headline = "B"
304
304
  book.pages << p3
305
- book.pages_change[0].should == pages
306
- book.pages_change[1].should be_a HashWithIndifferentAccess
307
- book.pages_change[1][:added].should == [p3]
308
- book.pages_change[1][:removed].should == [p1]
309
- book.pages_change[1][:changed][0][0].should be_a Page
310
- book.pages_change[1][:changed][0][0].headline.should == "A"
311
- book.pages_change[1][:changed][0][1].should == p2.changes
305
+ expect(book.pages_change[0]).to eq(pages)
306
+ expect(book.pages_change[1]).to be_a HashWithIndifferentAccess
307
+ expect(book.pages_change[1][:added]).to eq([p3])
308
+ expect(book.pages_change[1][:removed]).to eq([p1])
309
+ expect(book.pages_change[1][:changed][0][0]).to be_a Page
310
+ expect(book.pages_change[1][:changed][0][0].headline).to eq("A")
311
+ expect(book.pages_change[1][:changed][0][1]).to eq(p2.changes)
312
312
  end
313
313
 
314
314
  it "returns added items when changing from nil to an array" do
@@ -316,28 +316,28 @@ describe "deep dirty attribute tracking" do
316
316
  p2 = Page.new(:headline => "A")
317
317
  book = Book.new
318
318
  book.pages = [p1, p2]
319
- book.pages_change[0].should == []
320
- book.pages_change[1].should be_a HashWithIndifferentAccess
321
- book.pages_change[1][:added].should == [p1, p2]
322
- book.pages_change[1][:removed].should == []
323
- book.pages_change[1][:changed].should == []
319
+ expect(book.pages_change[0]).to eq([])
320
+ expect(book.pages_change[1]).to be_a HashWithIndifferentAccess
321
+ expect(book.pages_change[1][:added]).to eq([p1, p2])
322
+ expect(book.pages_change[1][:removed]).to eq([])
323
+ expect(book.pages_change[1][:changed]).to eq([])
324
324
  end
325
325
 
326
326
  it "does not return unchanged cloned items as changes" do
327
327
  book = Book.new(:pages => [Page.new(:number => 1)])
328
328
  book.pages[0] = book.pages[0].clone
329
- book.pages_change.should be_nil
329
+ expect(book.pages_change).to be_nil
330
330
  end
331
331
 
332
332
  it "returns changes if an item is replaced with changes but the same _id" do
333
333
  book = Book.new(:pages => [Page.new(:_id => "pid", :number => 1)])
334
334
  pages = book.pages.clone
335
335
  book.pages[0] = Page.new(:_id => "pid", :number => 2)
336
- book.pages_change[0].should == pages
337
- book.pages_change[1].should be_a HashWithIndifferentAccess
338
- book.pages_change[1][:added].should == []
339
- book.pages_change[1][:removed].should == []
340
- book.pages_change[1][:changed].should == [[pages[0], {"number" => [1, 2]}]]
336
+ expect(book.pages_change[0]).to eq(pages)
337
+ expect(book.pages_change[1]).to be_a HashWithIndifferentAccess
338
+ expect(book.pages_change[1][:added]).to eq([])
339
+ expect(book.pages_change[1][:removed]).to eq([])
340
+ expect(book.pages_change[1][:changed]).to eq([[pages[0], {"number" => [1, 2]}]])
341
341
  end
342
342
  end
343
343
  end
@@ -346,48 +346,48 @@ describe "deep dirty attribute tracking" do
346
346
  it "includes simple property changes" do
347
347
  book = Book.new(:title => "Title A")
348
348
  book.title = "Title B"
349
- book.changes[:title].should == book.title_change
349
+ expect(book.changes[:title]).to eq(book.title_change)
350
350
  end
351
351
 
352
352
  it "includes embedded document changes" do
353
353
  book = Book.new(:cover => Cover.new(:color => "red"))
354
354
  cover = book.cover.clone
355
355
  book.cover.color = "blue"
356
- book.changes[:cover].should == book.cover_change
356
+ expect(book.changes[:cover]).to eq(book.cover_change)
357
357
  end
358
358
 
359
359
  it "does not include unchanged embedded documents" do
360
360
  book = Book.new(:cover => Cover.new(:color => "red"))
361
- book.changes.should_not have_key :cover
361
+ expect(book.changes).not_to have_key :cover
362
362
  end
363
363
 
364
364
  it "includes simple array changes" do
365
365
  book = Book.new(:authors => ["Sarah"])
366
366
  book.authors = ["Jane"]
367
- book.changes[:authors].should == book.authors_change
367
+ expect(book.changes[:authors]).to eq(book.authors_change)
368
368
  end
369
369
 
370
370
  it "does not include unchanged simple arrays" do
371
371
  book = Book.new(:authors => ["Sarah"])
372
- book.changes.should_not have_key :authors
372
+ expect(book.changes).not_to have_key :authors
373
373
  end
374
374
 
375
375
  it "includes document array changes" do
376
376
  book = Book.new(:pages => [Page.new(:number => 1)])
377
377
  book.pages = [Page.new(:number => 2)]
378
- book.changes[:pages].should == book.pages_change
378
+ expect(book.changes[:pages]).to eq(book.pages_change)
379
379
  end
380
380
 
381
381
  it "does not include unchanged document arrays" do
382
382
  book = Book.new(:pages => [Page.new(:number => 1)])
383
- book.changes.should_not have_key :pages
383
+ expect(book.changes).not_to have_key :pages
384
384
  end
385
385
  end
386
386
 
387
387
  describe "after save" do
388
388
  before :each do
389
389
  book = Book.json_create(:_id => "1", :title => "A", :cover => {:color => "red"}, :pages => [{:_id => "p1", :number => 1}, {:_id => "p2", :number => 2}])
390
- @couchrest_db = stub('database', :info => nil, :save_doc => {}, :get => book)
390
+ @couchrest_db = double('database', :info => nil, :save_doc => {}, :get => book)
391
391
  @db = CouchPotato::Database.new(@couchrest_db)
392
392
  @book = @db.load_document "1"
393
393
  end
@@ -396,30 +396,30 @@ describe "deep dirty attribute tracking" do
396
396
  @book.title = "B"
397
397
  @book.cover.color = "blue"
398
398
  @db.save! @book
399
- @book.should_not be_dirty
400
- @book.cover.should_not be_dirty
399
+ expect(@book).not_to be_dirty
400
+ expect(@book.cover).not_to be_dirty
401
401
  end
402
402
 
403
403
  it "should reset all elements in a document array" do
404
404
  @book.pages.each(&:is_dirty)
405
405
  @db.save! @book
406
- @book.should_not be_dirty
406
+ expect(@book).not_to be_dirty
407
407
  @book.pages.each do |page|
408
- page.should_not be_dirty
408
+ expect(page).not_to be_dirty
409
409
  end
410
410
  end
411
411
 
412
412
  it "should reset a forced dirty state" do
413
413
  @book.is_dirty
414
414
  @db.save! @book
415
- @book.should_not be_dirty
415
+ expect(@book).not_to be_dirty
416
416
  end
417
417
 
418
418
  it "clears old values" do
419
419
  @book.cover.color = "blue"
420
420
  @db.save! @book
421
- @book.cover_was.should be_nil
422
- @book.cover_change.should be_nil
421
+ expect(@book.cover_was).to be_nil
422
+ expect(@book.cover_change).to be_nil
423
423
  end
424
424
  end
425
425
 
@@ -427,8 +427,8 @@ describe "deep dirty attribute tracking" do
427
427
  it "still uses deep dirty tracking" do
428
428
  book = TextBook.new(:pages => [Page.new(:number => 1)])
429
429
  book.pages[0].number = 2
430
- book.should be_pages_changed
431
- book.should be_changed
430
+ expect(book).to be_pages_changed
431
+ expect(book).to be_changed
432
432
  end
433
433
  end
434
434
  end