dirty_hashy 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +7 -0
- data/README.textile +29 -20
- data/VERSION +1 -1
- data/dirty_hashy.gemspec +1 -1
- data/lib/dirty.rb +2 -0
- data/lib/dirty/attributes.rb +39 -0
- data/lib/dirty/hash.rb +108 -0
- data/lib/dirty_hashy.rb +4 -84
- data/lib/dirty_hashy/version.rb +3 -3
- data/lib/dirty_indifferent_hashy.rb +5 -0
- data/test/unit/dirty/test_attributes.rb +176 -0
- data/test/unit/test_dirty_hashy.rb +109 -94
- data/test/unit/test_dirty_indifferent_hashy.rb +500 -0
- metadata +47 -35
- data/lib/dirty_attributes.rb +0 -37
- data/test/unit/test_dirty_attributes.rb +0 -174
@@ -20,29 +20,29 @@ module Unit
|
|
20
20
|
|
21
21
|
assert_equal true, hashy.dirty?
|
22
22
|
assert_equal true, hashy.changed?
|
23
|
-
assert_equal
|
23
|
+
assert_equal false, hashy.changed?(:name)
|
24
24
|
assert_equal true, hashy.changed?("name")
|
25
|
-
assert_equal
|
25
|
+
assert_equal nil, hashy.change(:name)
|
26
26
|
assert_equal [nil, "Paul"], hashy.change("name")
|
27
27
|
assert_equal({"name" => [nil, "Paul"]}, hashy.changes)
|
28
28
|
|
29
29
|
hashy[:name] = nil
|
30
30
|
|
31
|
-
assert_equal
|
32
|
-
assert_equal
|
31
|
+
assert_equal true, hashy.dirty?
|
32
|
+
assert_equal true, hashy.changed?
|
33
33
|
assert_equal false, hashy.changed?(:name)
|
34
|
-
assert_equal
|
34
|
+
assert_equal true, hashy.changed?("name")
|
35
35
|
assert_equal nil, hashy.change(:name)
|
36
|
-
assert_equal nil, hashy.change("name")
|
37
|
-
assert_equal({}, hashy.changes)
|
36
|
+
assert_equal [nil, "Paul"], hashy.change("name")
|
37
|
+
assert_equal({"name" => [nil, "Paul"]}, hashy.changes)
|
38
38
|
|
39
39
|
hashy["name"] = "Stephan"
|
40
40
|
|
41
41
|
assert_equal true, hashy.dirty?
|
42
42
|
assert_equal true, hashy.changed?
|
43
|
-
assert_equal
|
43
|
+
assert_equal false, hashy.changed?(:name)
|
44
44
|
assert_equal true, hashy.changed?("name")
|
45
|
-
assert_equal
|
45
|
+
assert_equal nil, hashy.change(:name)
|
46
46
|
assert_equal [nil, "Stephan"], hashy.change("name")
|
47
47
|
assert_equal({"name" => [nil, "Stephan"]}, hashy.changes)
|
48
48
|
|
@@ -60,9 +60,9 @@ module Unit
|
|
60
60
|
|
61
61
|
assert_equal true, hashy.dirty?
|
62
62
|
assert_equal true, hashy.changed?
|
63
|
-
assert_equal
|
63
|
+
assert_equal false, hashy.changed?(:name)
|
64
64
|
assert_equal true, hashy.changed?("name")
|
65
|
-
assert_equal
|
65
|
+
assert_equal nil, hashy.change(:name)
|
66
66
|
assert_equal ["Stephan", "Chris"], hashy.change("name")
|
67
67
|
assert_equal({"name" => ["Stephan", "Chris"]}, hashy.changes)
|
68
68
|
|
@@ -76,15 +76,15 @@ module Unit
|
|
76
76
|
assert_equal nil, hashy.change("name")
|
77
77
|
assert_equal({}, hashy.changes)
|
78
78
|
|
79
|
-
hashy[
|
79
|
+
hashy[:name] = "Paul"
|
80
80
|
|
81
81
|
assert_equal true, hashy.dirty?
|
82
82
|
assert_equal true, hashy.changed?
|
83
83
|
assert_equal true, hashy.changed?(:name)
|
84
|
-
assert_equal
|
85
|
-
assert_equal [
|
86
|
-
assert_equal
|
87
|
-
assert_equal({
|
84
|
+
assert_equal false, hashy.changed?("name")
|
85
|
+
assert_equal [nil, "Paul"], hashy.change(:name)
|
86
|
+
assert_equal nil, hashy.change("name")
|
87
|
+
assert_equal({:name => [nil, "Paul"]}, hashy.changes)
|
88
88
|
|
89
89
|
hashy["name"] = "Tim"
|
90
90
|
|
@@ -92,9 +92,9 @@ module Unit
|
|
92
92
|
assert_equal true, hashy.changed?
|
93
93
|
assert_equal true, hashy.changed?(:name)
|
94
94
|
assert_equal true, hashy.changed?("name")
|
95
|
-
assert_equal [
|
95
|
+
assert_equal [nil, "Paul"], hashy.change(:name)
|
96
96
|
assert_equal ["Stephan", "Tim"], hashy.change("name")
|
97
|
-
assert_equal({"name" => ["Stephan", "Tim"]}, hashy.changes)
|
97
|
+
assert_equal({:name => [nil, "Paul"], "name" => ["Stephan", "Tim"]}, hashy.changes)
|
98
98
|
|
99
99
|
hashy["company"] = "Holder"
|
100
100
|
|
@@ -102,19 +102,19 @@ module Unit
|
|
102
102
|
assert_equal true, hashy.changed?
|
103
103
|
assert_equal true, hashy.changed?(:name)
|
104
104
|
assert_equal true, hashy.changed?("name")
|
105
|
-
assert_equal
|
105
|
+
assert_equal false, hashy.changed?(:company)
|
106
106
|
assert_equal true, hashy.changed?("company")
|
107
|
-
assert_equal [
|
107
|
+
assert_equal [nil, "Paul"], hashy.change(:name)
|
108
108
|
assert_equal ["Stephan", "Tim"], hashy.change("name")
|
109
|
-
assert_equal
|
109
|
+
assert_equal nil, hashy.change(:company)
|
110
110
|
assert_equal [nil, "Holder"], hashy.change("company")
|
111
|
-
assert_equal({"name" => ["Stephan", "Tim"], "company" => [nil, "Holder"]}, hashy.changes)
|
111
|
+
assert_equal({:name => [nil, "Paul"], "name" => ["Stephan", "Tim"], "company" => [nil, "Holder"]}, hashy.changes)
|
112
112
|
|
113
113
|
hashy["city"] = "Amsterdam"
|
114
|
-
assert_equal({"name" => ["Stephan", "Tim"], "company" => [nil, "Holder"], "city" => [nil, "Amsterdam"]}, hashy.changes)
|
114
|
+
assert_equal({:name => [nil, "Paul"], "name" => ["Stephan", "Tim"], "company" => [nil, "Holder"], "city" => [nil, "Amsterdam"]}, hashy.changes)
|
115
115
|
|
116
|
-
hashy.delete
|
117
|
-
assert_equal({"name" => ["Stephan", "Tim"], "company" => [nil, "Holder"]}, hashy.changes)
|
116
|
+
hashy.delete "city"
|
117
|
+
assert_equal({:name => [nil, "Paul"], "name" => ["Stephan", "Tim"], "company" => [nil, "Holder"]}, hashy.changes)
|
118
118
|
|
119
119
|
hashy.clean_up!
|
120
120
|
|
@@ -128,36 +128,36 @@ module Unit
|
|
128
128
|
assert_equal nil, hashy.change("company")
|
129
129
|
assert_equal({}, hashy.changes)
|
130
130
|
|
131
|
-
hashy.delete
|
131
|
+
hashy.delete "company"
|
132
132
|
|
133
133
|
assert_equal true, hashy.dirty?
|
134
134
|
assert_equal true, hashy.changed?
|
135
|
-
assert_equal
|
135
|
+
assert_equal false, hashy.changed?(:company)
|
136
136
|
assert_equal true, hashy.changed?("company")
|
137
|
-
assert_equal
|
137
|
+
assert_equal nil, hashy.was(:company)
|
138
138
|
assert_equal "Holder", hashy.was("company")
|
139
|
-
assert_equal
|
139
|
+
assert_equal nil, hashy.change(:company)
|
140
140
|
assert_equal ["Holder", nil], hashy.change("company")
|
141
141
|
|
142
|
-
hashy.merge! :name => "
|
142
|
+
hashy.merge! :name => "Anna", :company => "Internetbureau Holder B.V."
|
143
143
|
|
144
144
|
assert_equal true, hashy.dirty?
|
145
145
|
assert_equal true, hashy.changed?
|
146
146
|
assert_equal true, hashy.changed?(:name)
|
147
|
-
assert_equal
|
147
|
+
assert_equal false, hashy.changed?("name")
|
148
148
|
assert_equal true, hashy.changed?(:company)
|
149
149
|
assert_equal true, hashy.changed?("company")
|
150
|
-
assert_equal ["
|
151
|
-
assert_equal
|
152
|
-
assert_equal [
|
153
|
-
assert_equal ["Holder",
|
154
|
-
assert_equal({
|
150
|
+
assert_equal ["Paul", "Anna"], hashy.change(:name)
|
151
|
+
assert_equal nil, hashy.change("name")
|
152
|
+
assert_equal [nil, "Internetbureau Holder B.V."], hashy.change(:company)
|
153
|
+
assert_equal ["Holder", nil], hashy.change("company")
|
154
|
+
assert_equal({:name => ["Paul", "Anna"], :company => [nil, "Internetbureau Holder B.V."], "company" => ["Holder", nil]}, hashy.changes)
|
155
155
|
end
|
156
156
|
|
157
157
|
it "should behave as expected without method mapping, but with restricted keys" do
|
158
158
|
hashy = DirtyHashy.new({}, false, [:name])
|
159
159
|
|
160
|
-
assert_equal({
|
160
|
+
assert_equal({:name => nil}, hashy)
|
161
161
|
assert_equal false, hashy.dirty?
|
162
162
|
assert_equal false, hashy.changed?
|
163
163
|
assert_equal({}, hashy.changes)
|
@@ -166,24 +166,20 @@ module Unit
|
|
166
166
|
hashy.name = "Paul"
|
167
167
|
end
|
168
168
|
|
169
|
-
hashy[
|
169
|
+
hashy[:name] = "Paul"
|
170
170
|
|
171
171
|
assert_equal true, hashy.dirty?
|
172
172
|
assert_equal true, hashy.changed?
|
173
173
|
assert_equal true, hashy.changed?(:name)
|
174
|
-
assert_equal true, hashy.changed?("name")
|
175
174
|
assert_equal [nil, "Paul"], hashy.change(:name)
|
176
|
-
assert_equal [nil, "Paul"], hashy.
|
177
|
-
assert_equal({"name" => [nil, "Paul"]}, hashy.changes)
|
175
|
+
assert_equal({:name => [nil, "Paul"]}, hashy.changes)
|
178
176
|
|
179
177
|
hashy[:name] = nil
|
180
178
|
|
181
179
|
assert_equal false, hashy.dirty?
|
182
180
|
assert_equal false, hashy.changed?
|
183
181
|
assert_equal false, hashy.changed?(:name)
|
184
|
-
assert_equal false, hashy.changed?("name")
|
185
182
|
assert_equal nil, hashy.change(:name)
|
186
|
-
assert_equal nil, hashy.change("name")
|
187
183
|
assert_equal({}, hashy.changes)
|
188
184
|
|
189
185
|
hashy[:name] = "Stephan"
|
@@ -191,61 +187,49 @@ module Unit
|
|
191
187
|
assert_equal true, hashy.dirty?
|
192
188
|
assert_equal true, hashy.changed?
|
193
189
|
assert_equal true, hashy.changed?(:name)
|
194
|
-
assert_equal true, hashy.changed?("name")
|
195
190
|
assert_equal [nil, "Stephan"], hashy.change(:name)
|
196
|
-
assert_equal [nil, "Stephan"], hashy.
|
197
|
-
assert_equal({"name" => [nil, "Stephan"]}, hashy.changes)
|
191
|
+
assert_equal({:name => [nil, "Stephan"]}, hashy.changes)
|
198
192
|
|
199
193
|
hashy.clean_up!
|
200
194
|
|
201
195
|
assert_equal false, hashy.dirty?
|
202
196
|
assert_equal false, hashy.changed?
|
203
197
|
assert_equal false, hashy.changed?(:name)
|
204
|
-
assert_equal false, hashy.changed?("name")
|
205
198
|
assert_equal nil, hashy.change(:name)
|
206
|
-
assert_equal nil, hashy.change("name")
|
207
199
|
assert_equal({}, hashy.changes)
|
208
200
|
|
209
|
-
hashy[
|
201
|
+
hashy[:name] = "Chris"
|
210
202
|
|
211
203
|
assert_equal true, hashy.dirty?
|
212
204
|
assert_equal true, hashy.changed?
|
213
205
|
assert_equal true, hashy.changed?(:name)
|
214
|
-
assert_equal
|
215
|
-
assert_equal "Stephan", hashy.was("name")
|
206
|
+
assert_equal "Stephan", hashy.was(:name)
|
216
207
|
assert_equal ["Stephan", "Chris"], hashy.change(:name)
|
217
|
-
assert_equal ["Stephan", "Chris"], hashy.
|
218
|
-
assert_equal({"name" => ["Stephan", "Chris"]}, hashy.changes)
|
208
|
+
assert_equal({:name => ["Stephan", "Chris"]}, hashy.changes)
|
219
209
|
|
220
|
-
hashy[
|
210
|
+
hashy[:name] = "Stephan"
|
221
211
|
|
222
212
|
assert_equal false, hashy.dirty?
|
223
213
|
assert_equal false, hashy.changed?
|
224
214
|
assert_equal false, hashy.changed?(:name)
|
225
|
-
assert_equal false, hashy.changed?("name")
|
226
215
|
assert_equal nil, hashy.change(:name)
|
227
|
-
assert_equal nil, hashy.change("name")
|
228
216
|
assert_equal({}, hashy.changes)
|
229
217
|
|
230
|
-
hashy[
|
218
|
+
hashy[:name] = "Paul"
|
231
219
|
|
232
220
|
assert_equal true, hashy.dirty?
|
233
221
|
assert_equal true, hashy.changed?
|
234
222
|
assert_equal true, hashy.changed?(:name)
|
235
|
-
assert_equal true, hashy.changed?("name")
|
236
223
|
assert_equal ["Stephan", "Paul"], hashy.change(:name)
|
237
|
-
assert_equal ["Stephan", "Paul"], hashy.
|
238
|
-
assert_equal({"name" => ["Stephan", "Paul"]}, hashy.changes)
|
224
|
+
assert_equal({:name => ["Stephan", "Paul"]}, hashy.changes)
|
239
225
|
|
240
|
-
hashy[
|
226
|
+
hashy[:name] = "Tim"
|
241
227
|
|
242
228
|
assert_equal true, hashy.dirty?
|
243
229
|
assert_equal true, hashy.changed?
|
244
230
|
assert_equal true, hashy.changed?(:name)
|
245
|
-
assert_equal true, hashy.changed?("name")
|
246
231
|
assert_equal ["Stephan", "Tim"], hashy.change(:name)
|
247
|
-
assert_equal ["Stephan", "Tim"], hashy.
|
248
|
-
assert_equal({"name" => ["Stephan", "Tim"]}, hashy.changes)
|
232
|
+
assert_equal({:name => ["Stephan", "Tim"]}, hashy.changes)
|
249
233
|
|
250
234
|
hashy.clean_up!
|
251
235
|
hashy.merge! :name => "Paul"
|
@@ -253,10 +237,16 @@ module Unit
|
|
253
237
|
assert_equal true, hashy.dirty?
|
254
238
|
assert_equal true, hashy.changed?
|
255
239
|
assert_equal true, hashy.changed?(:name)
|
256
|
-
assert_equal true, hashy.changed?("name")
|
257
240
|
assert_equal ["Tim", "Paul"], hashy.change(:name)
|
258
|
-
assert_equal ["Tim", "Paul"], hashy.
|
259
|
-
|
241
|
+
assert_equal({:name => ["Tim", "Paul"]}, hashy.changes)
|
242
|
+
|
243
|
+
assert_raises(IndexError) do
|
244
|
+
hashy["name"] = "Paul"
|
245
|
+
end
|
246
|
+
|
247
|
+
assert_raises(IndexError) do
|
248
|
+
hashy.changed? "name"
|
249
|
+
end
|
260
250
|
|
261
251
|
assert_raises(IndexError) do
|
262
252
|
hashy[:company]
|
@@ -305,9 +295,11 @@ module Unit
|
|
305
295
|
assert_equal true, hashy.dirty?
|
306
296
|
assert_equal true, hashy.changed?
|
307
297
|
assert_equal true, hashy.name_changed?
|
308
|
-
assert_equal
|
298
|
+
assert_equal false, hashy.changed?(:name)
|
299
|
+
assert_equal true, hashy.changed?("name")
|
309
300
|
assert_equal [nil, "Paul"], hashy.name_change
|
310
|
-
assert_equal
|
301
|
+
assert_equal nil, hashy.change(:name)
|
302
|
+
assert_equal [nil, "Paul"], hashy.change("name")
|
311
303
|
assert_equal({"name" => [nil, "Paul"]}, hashy.changes)
|
312
304
|
|
313
305
|
hashy.name = nil
|
@@ -316,8 +308,10 @@ module Unit
|
|
316
308
|
assert_equal false, hashy.changed?
|
317
309
|
assert_equal false, hashy.name_changed?
|
318
310
|
assert_equal false, hashy.changed?(:name)
|
311
|
+
assert_equal false, hashy.changed?("name")
|
319
312
|
assert_equal nil, hashy.name_change
|
320
313
|
assert_equal nil, hashy.change(:name)
|
314
|
+
assert_equal nil, hashy.change("name")
|
321
315
|
assert_equal({}, hashy.changes)
|
322
316
|
|
323
317
|
hashy.name = "Stephan"
|
@@ -325,9 +319,11 @@ module Unit
|
|
325
319
|
assert_equal true, hashy.dirty?
|
326
320
|
assert_equal true, hashy.changed?
|
327
321
|
assert_equal true, hashy.name_changed?
|
328
|
-
assert_equal
|
322
|
+
assert_equal false, hashy.changed?(:name)
|
323
|
+
assert_equal true, hashy.changed?("name")
|
329
324
|
assert_equal [nil, "Stephan"], hashy.name_change
|
330
|
-
assert_equal
|
325
|
+
assert_equal nil, hashy.change(:name)
|
326
|
+
assert_equal [nil, "Stephan"], hashy.change("name")
|
331
327
|
assert_equal({"name" => [nil, "Stephan"]}, hashy.changes)
|
332
328
|
|
333
329
|
hashy.clean_up!
|
@@ -336,8 +332,10 @@ module Unit
|
|
336
332
|
assert_equal false, hashy.changed?
|
337
333
|
assert_equal false, hashy.name_changed?
|
338
334
|
assert_equal false, hashy.changed?(:name)
|
335
|
+
assert_equal false, hashy.changed?("name")
|
339
336
|
assert_equal nil, hashy.name_change
|
340
337
|
assert_equal nil, hashy.change(:name)
|
338
|
+
assert_equal nil, hashy.change("name")
|
341
339
|
assert_equal({}, hashy.changes)
|
342
340
|
|
343
341
|
hashy.name = "Chris"
|
@@ -345,11 +343,14 @@ module Unit
|
|
345
343
|
assert_equal true, hashy.dirty?
|
346
344
|
assert_equal true, hashy.changed?
|
347
345
|
assert_equal true, hashy.name_changed?
|
348
|
-
assert_equal
|
346
|
+
assert_equal false, hashy.changed?(:name)
|
347
|
+
assert_equal true, hashy.changed?("name")
|
349
348
|
assert_equal "Stephan", hashy.name_was
|
350
|
-
assert_equal
|
349
|
+
assert_equal nil, hashy.was(:name)
|
350
|
+
assert_equal "Stephan", hashy.was("name")
|
351
351
|
assert_equal ["Stephan", "Chris"], hashy.name_change
|
352
|
-
assert_equal
|
352
|
+
assert_equal nil, hashy.change(:name)
|
353
|
+
assert_equal ["Stephan", "Chris"], hashy.change("name")
|
353
354
|
assert_equal({"name" => ["Stephan", "Chris"]}, hashy.changes)
|
354
355
|
|
355
356
|
hashy.name = "Stephan"
|
@@ -358,35 +359,41 @@ module Unit
|
|
358
359
|
assert_equal false, hashy.changed?
|
359
360
|
assert_equal false, hashy.name_changed?
|
360
361
|
assert_equal false, hashy.changed?(:name)
|
362
|
+
assert_equal false, hashy.changed?("name")
|
361
363
|
assert_equal nil, hashy.name_change
|
362
364
|
assert_equal nil, hashy.change(:name)
|
365
|
+
assert_equal nil, hashy.change("name")
|
363
366
|
assert_equal({}, hashy.changes)
|
364
367
|
|
365
368
|
hashy.name = "Tim"
|
366
369
|
hashy.city = "Amsterdam"
|
367
370
|
|
368
371
|
assert_equal true, hashy.city_changed?
|
369
|
-
assert_equal
|
372
|
+
assert_equal false, hashy.changed?(:city)
|
373
|
+
assert_equal true, hashy.changed?("city")
|
370
374
|
assert_equal nil, hashy.city_was
|
371
375
|
assert_equal [nil, "Amsterdam"], hashy.city_change
|
372
376
|
assert_equal({"name" => ["Stephan", "Tim"], "city" => [nil, "Amsterdam"]}, hashy.changes)
|
373
377
|
|
374
378
|
hashy.delete :city
|
379
|
+
assert_equal({"name" => ["Stephan", "Tim"], "city" => [nil, "Amsterdam"]}, hashy.changes)
|
380
|
+
|
381
|
+
hashy.delete "city"
|
375
382
|
assert_equal({"name" => ["Stephan", "Tim"]}, hashy.changes)
|
376
383
|
|
377
384
|
hashy.merge! :company => "Internetbureau Holder B.V."
|
378
385
|
|
379
386
|
assert_equal true, hashy.dirty?
|
380
387
|
assert_equal true, hashy.changed?
|
381
|
-
assert_equal
|
388
|
+
assert_equal false, hashy.changed?(:name)
|
382
389
|
assert_equal true, hashy.changed?("name")
|
383
390
|
assert_equal true, hashy.changed?(:company)
|
384
|
-
assert_equal
|
385
|
-
assert_equal
|
391
|
+
assert_equal false, hashy.changed?("company")
|
392
|
+
assert_equal nil, hashy.change(:name)
|
386
393
|
assert_equal ["Stephan", "Tim"], hashy.change("name")
|
387
394
|
assert_equal [nil, "Internetbureau Holder B.V."], hashy.change(:company)
|
388
|
-
assert_equal
|
389
|
-
assert_equal({"name" => ["Stephan", "Tim"],
|
395
|
+
assert_equal nil, hashy.change("company")
|
396
|
+
assert_equal({"name" => ["Stephan", "Tim"], :company => [nil, "Internetbureau Holder B.V."]}, hashy.changes)
|
390
397
|
|
391
398
|
hashy.clean_up!
|
392
399
|
|
@@ -395,7 +402,7 @@ module Unit
|
|
395
402
|
end
|
396
403
|
|
397
404
|
it "should behave as expected with method mapping and with restricted keys" do
|
398
|
-
hashy = DirtyHashy.new({}, true, [:name])
|
405
|
+
hashy = DirtyHashy.new({}, true, [:name]) # NOTE: using method mapping AND restricted keys stringifies the restricted keys
|
399
406
|
|
400
407
|
assert_equal({"name" => nil}, hashy)
|
401
408
|
assert_equal nil, hashy.name
|
@@ -409,9 +416,9 @@ module Unit
|
|
409
416
|
assert_equal true, hashy.dirty?
|
410
417
|
assert_equal true, hashy.changed?
|
411
418
|
assert_equal true, hashy.name_changed?
|
412
|
-
assert_equal true, hashy.changed?(
|
419
|
+
assert_equal true, hashy.changed?("name")
|
413
420
|
assert_equal [nil, "Paul"], hashy.name_change
|
414
|
-
assert_equal [nil, "Paul"], hashy.change(
|
421
|
+
assert_equal [nil, "Paul"], hashy.change("name")
|
415
422
|
assert_equal({"name" => [nil, "Paul"]}, hashy.changes)
|
416
423
|
|
417
424
|
hashy.name = nil
|
@@ -419,9 +426,9 @@ module Unit
|
|
419
426
|
assert_equal false, hashy.dirty?
|
420
427
|
assert_equal false, hashy.changed?
|
421
428
|
assert_equal false, hashy.name_changed?
|
422
|
-
assert_equal false, hashy.changed?(
|
429
|
+
assert_equal false, hashy.changed?("name")
|
423
430
|
assert_equal nil, hashy.name_change
|
424
|
-
assert_equal nil, hashy.change(
|
431
|
+
assert_equal nil, hashy.change("name")
|
425
432
|
assert_equal({}, hashy.changes)
|
426
433
|
|
427
434
|
hashy.name = "Stephan"
|
@@ -429,9 +436,9 @@ module Unit
|
|
429
436
|
assert_equal true, hashy.dirty?
|
430
437
|
assert_equal true, hashy.changed?
|
431
438
|
assert_equal true, hashy.name_changed?
|
432
|
-
assert_equal true, hashy.changed?(
|
439
|
+
assert_equal true, hashy.changed?("name")
|
433
440
|
assert_equal [nil, "Stephan"], hashy.name_change
|
434
|
-
assert_equal [nil, "Stephan"], hashy.change(
|
441
|
+
assert_equal [nil, "Stephan"], hashy.change("name")
|
435
442
|
assert_equal({"name" => [nil, "Stephan"]}, hashy.changes)
|
436
443
|
|
437
444
|
hashy.clean_up!
|
@@ -439,9 +446,9 @@ module Unit
|
|
439
446
|
assert_equal false, hashy.dirty?
|
440
447
|
assert_equal false, hashy.changed?
|
441
448
|
assert_equal false, hashy.name_changed?
|
442
|
-
assert_equal false, hashy.changed?(
|
449
|
+
assert_equal false, hashy.changed?("name")
|
443
450
|
assert_equal nil, hashy.name_change
|
444
|
-
assert_equal nil, hashy.change(
|
451
|
+
assert_equal nil, hashy.change("name")
|
445
452
|
assert_equal({}, hashy.changes)
|
446
453
|
|
447
454
|
hashy.name = "Chris"
|
@@ -449,11 +456,11 @@ module Unit
|
|
449
456
|
assert_equal true, hashy.dirty?
|
450
457
|
assert_equal true, hashy.changed?
|
451
458
|
assert_equal true, hashy.name_changed?
|
452
|
-
assert_equal true, hashy.changed?(
|
459
|
+
assert_equal true, hashy.changed?("name")
|
453
460
|
assert_equal "Stephan", hashy.name_was
|
454
|
-
assert_equal "Stephan", hashy.was(
|
461
|
+
assert_equal "Stephan", hashy.was("name")
|
455
462
|
assert_equal ["Stephan", "Chris"], hashy.name_change
|
456
|
-
assert_equal ["Stephan", "Chris"], hashy.change(
|
463
|
+
assert_equal ["Stephan", "Chris"], hashy.change("name")
|
457
464
|
assert_equal({"name" => ["Stephan", "Chris"]}, hashy.changes)
|
458
465
|
|
459
466
|
hashy.name = "Stephan"
|
@@ -461,11 +468,19 @@ module Unit
|
|
461
468
|
assert_equal false, hashy.dirty?
|
462
469
|
assert_equal false, hashy.changed?
|
463
470
|
assert_equal false, hashy.name_changed?
|
464
|
-
assert_equal false, hashy.changed?(
|
471
|
+
assert_equal false, hashy.changed?("name")
|
465
472
|
assert_equal nil, hashy.name_change
|
466
|
-
assert_equal nil, hashy.change(
|
473
|
+
assert_equal nil, hashy.change("name")
|
467
474
|
assert_equal({}, hashy.changes)
|
468
475
|
|
476
|
+
assert_raises(IndexError) do
|
477
|
+
hashy.changed? :name
|
478
|
+
end
|
479
|
+
|
480
|
+
assert_raises(IndexError) do
|
481
|
+
hashy.change :name
|
482
|
+
end
|
483
|
+
|
469
484
|
assert_raises(NoMethodError) do
|
470
485
|
hashy.company
|
471
486
|
end
|