rspec-active_record 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -0
- data/README.md +8 -0
- data/lib/rspec/active_record/change_record.rb +7 -2
- data/lib/rspec/active_record/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a7a6ee8d2f8e4e3230227c54f7b6ac9484820e2d7316b7a286529f7b96fcf168
|
|
4
|
+
data.tar.gz: 7544437ce608ee8190a98631c3a9ac81839e9a137f598826383e90950e8d7ea8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e6e48ae2fef14172a456daa012eea9eeb94f53ddabb54db89e5b469f6d51c68b55386374b58836358d311d1fb77353bbffc4768927123de75968882bf2ce2b4f
|
|
7
|
+
data.tar.gz: acdf577a588b6da64e5233ab0c875cbbc38d8896218f24ef2f298928c5697b4b5fb6271671910a32f1358c82e263600a30270b36a729afcf37e11c833bfcf613
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -66,6 +66,14 @@ expect { user.update!(name: "RSpec User") }.to change_record(user).from(name: "I
|
|
|
66
66
|
expect { user.name = "RSpec User" }.to not_change_record(user).from(name: "Initial Name")
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
+
Use `attributes` to take the initial values from the record, equivalent to
|
|
70
|
+
`from(name: user.name, id: user.id)`:
|
|
71
|
+
```ruby
|
|
72
|
+
expect { user.update!(name: "RSpec User", email: "user@example.com") }
|
|
73
|
+
.to change_record(user).attributes(:name, :email)
|
|
74
|
+
expect { user.name = "RSpec User" }.to not_change_record(user).attributes(:name, :id)
|
|
75
|
+
```
|
|
76
|
+
|
|
69
77
|
### destroy_record
|
|
70
78
|
|
|
71
79
|
Check that code destroys a record:
|
|
@@ -18,6 +18,11 @@ module RSpec
|
|
|
18
18
|
self
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
# Use the record's current values as the initial attributes
|
|
22
|
+
def attributes(*names)
|
|
23
|
+
from(names.index_with { |name| @record.public_send(name) })
|
|
24
|
+
end
|
|
25
|
+
|
|
21
26
|
def matches?(block)
|
|
22
27
|
@from_diff = diff_unless_match(@record, @from)
|
|
23
28
|
@to_pre_match = !not_match_attributes?(@record, @to)
|
|
@@ -60,7 +65,7 @@ module RSpec
|
|
|
60
65
|
elsif @to_diff
|
|
61
66
|
"expected to change #{format_record} to #{format_hash(@to)} but did not#{@to_diff}"
|
|
62
67
|
else
|
|
63
|
-
"please specify from or to for change_record"
|
|
68
|
+
"please specify attributes, from or to for change_record"
|
|
64
69
|
end
|
|
65
70
|
end
|
|
66
71
|
|
|
@@ -68,7 +73,7 @@ module RSpec
|
|
|
68
73
|
if @to
|
|
69
74
|
"negative matcher for change_record with to is not supported"
|
|
70
75
|
elsif @from.blank?
|
|
71
|
-
"negative matcher for change_record without from is not supported"
|
|
76
|
+
"negative matcher for change_record without attributes or from is not supported"
|
|
72
77
|
elsif @from_diff
|
|
73
78
|
"expected #{format_record} to match #{format_hash(@from)} initially but it did not#{@from_diff}"
|
|
74
79
|
elsif !@from_post_match
|