composed_validations 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/composed_validations/and_validator.rb +2 -2
- data/lib/composed_validations/or_validator.rb +2 -2
- data/lib/composed_validations/version.rb +1 -1
- data/lib/composed_validations/with_validated_property.rb +1 -1
- data/spec/composed_validations/and_validator_spec.rb +2 -2
- data/spec/composed_validations/or_validator_spec.rb +2 -2
- data/spec/composed_validations/with_validated_property_spec.rb +1 -1
- data/spec/integration/or_validation_spec.rb +2 -2
- data/spec/integration/validation_spec.rb +2 -2
- 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: 22ebe8805f62d416cfaaff61e6341ff5a3ea8b94
|
4
|
+
data.tar.gz: 01ae1de017cb090ce2d8a3956a3b23c8f2f7a4f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a5f6eef97ecb69089887584676ca5750bf4e389f6542e793234fe9bfd90bffffa62e5fcdd17389e525faefeeb0ae9de380675a846dceab2012b667ac0412f0f
|
7
|
+
data.tar.gz: 53510e6d473be82537cdc9e86ac48256fe8433c5d7dc1567541b4485c2423f2106e2f8d2f558a89e93060b7ddb82f97da18c3adde0ab728c0aa5d5a017cb5130
|
data/README.md
CHANGED
@@ -42,12 +42,12 @@ end
|
|
42
42
|
### Validators
|
43
43
|
|
44
44
|
Validators are objects which takes the result of using a property accessor and
|
45
|
-
says whether or not it's valid. It responds to `
|
45
|
+
says whether or not it's valid. It responds to `valid_value?(value)` and `message`(the
|
46
46
|
message which gets added to errors if this is not valid.)
|
47
47
|
|
48
48
|
```ruby
|
49
49
|
class StringIsBob
|
50
|
-
def
|
50
|
+
def valid_value?(value)
|
51
51
|
value.to_s == "Bob"
|
52
52
|
end
|
53
53
|
|
@@ -8,7 +8,7 @@ RSpec.describe ComposedValidations::AndValidator do
|
|
8
8
|
|
9
9
|
describe "#valid?" do
|
10
10
|
let(:value) { double("value") }
|
11
|
-
let(:result) { subject.
|
11
|
+
let(:result) { subject.valid_value?(value) }
|
12
12
|
context "when both validators are valid" do
|
13
13
|
it "should return true" do
|
14
14
|
expect(result).to eq true
|
@@ -49,7 +49,7 @@ RSpec.describe ComposedValidations::AndValidator do
|
|
49
49
|
|
50
50
|
def mock_validator(valid:)
|
51
51
|
i = double("validator")
|
52
|
-
allow(i).to receive(:
|
52
|
+
allow(i).to receive(:valid_value?).and_return(valid)
|
53
53
|
allow(i).to receive(:message).and_return("message")
|
54
54
|
i
|
55
55
|
end
|
@@ -8,7 +8,7 @@ RSpec.describe ComposedValidations::OrValidator do
|
|
8
8
|
|
9
9
|
describe "#valid?" do
|
10
10
|
let(:value) { double("value") }
|
11
|
-
let(:result) { subject.
|
11
|
+
let(:result) { subject.valid_value?(value) }
|
12
12
|
context "when both validators are valid" do
|
13
13
|
it "should return true" do
|
14
14
|
expect(result).to eq true
|
@@ -36,7 +36,7 @@ RSpec.describe ComposedValidations::OrValidator do
|
|
36
36
|
|
37
37
|
def mock_validator(valid:)
|
38
38
|
i = double("validator")
|
39
|
-
allow(i).to receive(:
|
39
|
+
allow(i).to receive(:valid_value?).and_return(valid)
|
40
40
|
allow(i).to receive(:message).and_return("message")
|
41
41
|
i
|
42
42
|
end
|
@@ -28,7 +28,7 @@ RSpec.describe ComposedValidations::WithValidatedProperty do
|
|
28
28
|
let(:valid) { true }
|
29
29
|
let(:valid_result) { subject.valid? }
|
30
30
|
before do
|
31
|
-
allow(validator).to receive(:
|
31
|
+
allow(validator).to receive(:valid_value?).with(result).and_return(valid)
|
32
32
|
valid_result
|
33
33
|
end
|
34
34
|
it "should call asset.valid?" do
|
@@ -8,7 +8,7 @@ RSpec.describe "Or Validations Spec" do
|
|
8
8
|
attr_accessor :title, :description
|
9
9
|
end
|
10
10
|
class ValueIsFrank
|
11
|
-
def
|
11
|
+
def valid_value?(value)
|
12
12
|
value.to_s == "Frank"
|
13
13
|
end
|
14
14
|
|
@@ -17,7 +17,7 @@ RSpec.describe "Or Validations Spec" do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
class LengthIsFour
|
20
|
-
def
|
20
|
+
def valid_value?(value)
|
21
21
|
value.to_s.length == 4
|
22
22
|
end
|
23
23
|
|
@@ -8,7 +8,7 @@ RSpec.describe "Validations Integration Spec" do
|
|
8
8
|
attr_accessor :title, :description
|
9
9
|
end
|
10
10
|
class ValueIsFrank
|
11
|
-
def
|
11
|
+
def valid_value?(value)
|
12
12
|
value.to_s == "Frank"
|
13
13
|
end
|
14
14
|
|
@@ -17,7 +17,7 @@ RSpec.describe "Validations Integration Spec" do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
class LengthIsFive
|
20
|
-
def
|
20
|
+
def valid_value?(value)
|
21
21
|
value.to_s.length == 5
|
22
22
|
end
|
23
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: composed_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trey Terrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: attr_extras
|