assert-moar 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -3
- data/README.md +6 -0
- data/lib/assert_moar/assertions.rb +20 -0
- data/lib/assert_moar/version.rb +1 -1
- data/test/lib/assert_moar/assertions_test.rb +22 -0
- data/test/support/active_model/validations.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79dfc2889a6758823ab5f567e81a75fb0c5a91ed
|
4
|
+
data.tar.gz: 8908c3a207234970736e5a95431d8fe3c98f1ef1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9026d5f8b99b17e934a0dac3055b1524731c95d94e66b4c1e79f49939da49988c4222cb523be4939c14aa53d3968e61a7b335d0e08088aeeeab93903d65a9137
|
7
|
+
data.tar.gz: 49244e50dd6cafdc56359b9bb6e554717ad69cdedd101e8eebcaa029b1b3eb884bd746d1d84e89db8f4f642165b84f86cf3a9c0a82288b2022eb26c275ed92d5
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -25,8 +25,14 @@ Available methods:
|
|
25
25
|
```
|
26
26
|
#assert_valid
|
27
27
|
#refute_valid
|
28
|
+
#assert_validates_absence_of
|
29
|
+
#refute_validates_absence_of
|
30
|
+
#assert_validates_acceptance_of
|
31
|
+
#refute_validates_acceptance_of
|
28
32
|
#assert_validates_presence_of
|
29
33
|
#refute_validates_presence_of
|
34
|
+
#assert_validates_uniqueness_of
|
35
|
+
#refute_validates_uniqueness_of
|
30
36
|
```
|
31
37
|
|
32
38
|
## Contributing
|
@@ -19,6 +19,26 @@ module AssertMoar::Assertions
|
|
19
19
|
"#{object} validates presence of #{property}"
|
20
20
|
end
|
21
21
|
|
22
|
+
def assert_validates_absence_of(object, property)
|
23
|
+
assert has_validator?(object, property, ::ActiveModel::Validations::AbsenceValidator),
|
24
|
+
"#{object} does not validate the absence of #{property}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def refute_validates_absence_of(object, property)
|
28
|
+
refute has_validator?(object, property, ::ActiveModel::Validations::AbsenceValidator),
|
29
|
+
"#{object} validates absence of #{property}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def assert_validates_acceptance_of(object, property)
|
33
|
+
assert has_validator?(object, property, ::ActiveModel::Validations::AcceptanceValidator),
|
34
|
+
"#{object} does not validate the acceptance of #{property}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def refute_validates_acceptance_of(object, property)
|
38
|
+
refute has_validator?(object, property, ::ActiveModel::Validations::AcceptanceValidator),
|
39
|
+
"#{object} validates the acceptance of #{property}"
|
40
|
+
end
|
41
|
+
|
22
42
|
def assert_valid(object)
|
23
43
|
assert object.valid?, "Expected object to be valid"
|
24
44
|
end
|
data/lib/assert_moar/version.rb
CHANGED
@@ -41,6 +41,28 @@ class AssertMoar::AssertionTest < Minitest::Test
|
|
41
41
|
@tc.refute_validates_uniqueness_of(double, :property)
|
42
42
|
end
|
43
43
|
|
44
|
+
def test_assert_validates_absence_of
|
45
|
+
validator = ::ActiveModel::Validations::AbsenceValidator
|
46
|
+
double = ActiveRecordDouble.new(error_map: {property: validator })
|
47
|
+
@tc.assert_validates_absence_of(double, :property)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_refute_validates_absense_of
|
51
|
+
double = ActiveRecordDouble.new()
|
52
|
+
@tc.refute_validates_absence_of(double, :property)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_assert_validates_acceptance_of
|
56
|
+
validator = ::ActiveModel::Validations::AcceptanceValidator
|
57
|
+
double = ActiveRecordDouble.new(error_map: {property: validator})
|
58
|
+
@tc.assert_validates_acceptance_of(double, :property)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_refute_validates_acceptance_of
|
62
|
+
double = ActiveRecordDouble.new()
|
63
|
+
@tc.refute_validates_acceptance_of(double, :property)
|
64
|
+
end
|
65
|
+
|
44
66
|
def teardown
|
45
67
|
assert_equal(@assertion_count, @tc.assertions,
|
46
68
|
"expected #{@assertion_count} assertions to be fired during the test, not #{@tc.assertions}") if @tc.passed?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assert-moar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bohn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|