duck-hunt 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/duck-hunt/validators/greater_than.rb +5 -1
- data/lib/duck-hunt/validators/greater_than_or_equal_to.rb +5 -1
- data/lib/duck-hunt/validators/less_than.rb +5 -1
- data/lib/duck-hunt/validators/less_than_or_equal_to.rb +5 -1
- data/lib/duck-hunt/version.rb +1 -1
- data/test/properties/float_test.rb +1 -1
- data/test/properties/integer_test.rb +1 -1
- data/test/properties/numeric_test.rb +1 -1
- data/test/validators/greater_than_or_equal_to_test.rb +20 -0
- data/test/validators/greater_than_test.rb +19 -0
- data/test/validators/less_than_or_equal_to_test.rb +18 -0
- data/test/validators/less_than_test.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75d1dd61f15a97d225e5c9536b1af5146983565c57ac7de01d1dac4c1b7b679b
|
4
|
+
data.tar.gz: cc7eb8aa77af9aa931ee5431da737415b407ae78eac74cfddb0ec79d5ecc3441
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 351f223a9c7744958224e809aacaae26c87dc5e21489a29d55b41e5a0cd8c27870ff6716ad1f4b63353c93bf5f5b1bcfea707cbd97db8b2b9ba8a8df2aecc49e
|
7
|
+
data.tar.gz: d0c47052a4073c6133ec3c63967b25b29f1f7c185fa9906b4830fe15abf2e8c1b01eafdfecf943cf445b691b1d7a64378aa89fe34652192ff7d74b43a1018a4a
|
data/lib/duck-hunt/version.rb
CHANGED
@@ -13,7 +13,7 @@ describe DuckHunt::Properties::Float, "validation" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should be able to validate a BigDecimal floating point" do
|
16
|
-
bigdecimal = BigDecimal
|
16
|
+
bigdecimal = BigDecimal("3.4")
|
17
17
|
bigdecimal.must_be_instance_of BigDecimal
|
18
18
|
@property.valid?(bigdecimal).must_equal true
|
19
19
|
@property.errors.size.must_equal 0
|
@@ -39,7 +39,7 @@ describe DuckHunt::Properties::Integer, "validation" do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should not be able to parse a BigDecimal floating point" do
|
42
|
-
bigdecimal = BigDecimal
|
42
|
+
bigdecimal = BigDecimal("3.4")
|
43
43
|
bigdecimal.must_be_instance_of BigDecimal
|
44
44
|
@property.valid?(bigdecimal).must_equal false
|
45
45
|
@property.errors.size.must_equal 1
|
@@ -13,7 +13,7 @@ describe DuckHunt::Properties::Numeric, "validation" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should be able to validate a BigDecimal floating point" do
|
16
|
-
bigdecimal = BigDecimal
|
16
|
+
bigdecimal = BigDecimal("3.4")
|
17
17
|
bigdecimal.must_be_instance_of BigDecimal
|
18
18
|
@property.valid?(bigdecimal).must_equal true
|
19
19
|
@property.errors.size.must_equal 0
|
@@ -30,6 +30,26 @@ describe DuckHunt::Validators::GreaterThanOrEqualTo, "Validation" do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
|
33
|
+
describe DuckHunt::Validators::GreaterThanOrEqualTo, "Validation (length check)" do
|
34
|
+
before do
|
35
|
+
@validator = DuckHunt::Validators::GreaterThanOrEqualTo.new(3)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns true if the value provided is greater than or equal to the value given" do
|
39
|
+
@validator.valid?("aaaa").must_equal true
|
40
|
+
@validator.valid?([1,2,3,4]).must_equal true
|
41
|
+
@validator.valid?({a: 1, b: 2, c: 3}).must_equal true
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns false if the value provided is less than the value given" do
|
45
|
+
@validator.valid?("aa").must_equal false
|
46
|
+
@validator.valid?([1,2]).must_equal false
|
47
|
+
@validator.valid?({a: 1, b: 2}).must_equal false
|
48
|
+
@validator.valid?({}).must_equal false
|
49
|
+
@validator.valid?("").must_equal false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
33
53
|
|
34
54
|
describe DuckHunt::Validators::GreaterThanOrEqualTo, "error message" do
|
35
55
|
it "should have the correct error message based on the value provided" do
|
@@ -29,6 +29,25 @@ describe DuckHunt::Validators::GreaterThan, "Validation" do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
describe DuckHunt::Validators::GreaterThan, "Validation (length check)" do
|
33
|
+
before do
|
34
|
+
@validator = DuckHunt::Validators::GreaterThan.new(3)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns true if the value provided is greater than the value given" do
|
38
|
+
@validator.valid?("aaaa").must_equal true
|
39
|
+
@validator.valid?([1,2,3,4]).must_equal true
|
40
|
+
@validator.valid?({a: 1, b: 2, c: 3, d: 4}).must_equal true
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns false if the value provided is less than the value given" do
|
44
|
+
@validator.valid?("aaa").must_equal false
|
45
|
+
@validator.valid?([1,2,3]).must_equal false
|
46
|
+
@validator.valid?({a: 1, b: 2, c: 3}).must_equal false
|
47
|
+
@validator.valid?({}).must_equal false
|
48
|
+
@validator.valid?("").must_equal false
|
49
|
+
end
|
50
|
+
end
|
32
51
|
|
33
52
|
|
34
53
|
describe DuckHunt::Validators::GreaterThan, "error message" do
|
@@ -30,6 +30,24 @@ describe DuckHunt::Validators::LessThanOrEqualTo, "Validation" do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
describe DuckHunt::Validators::LessThanOrEqualTo, "Validation (length check)" do
|
34
|
+
before do
|
35
|
+
@validator = DuckHunt::Validators::LessThanOrEqualTo.new(3)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns true if the value provided is less than or equal to the value given" do
|
39
|
+
@validator.valid?("aaa").must_equal true
|
40
|
+
@validator.valid?([1,2]).must_equal true
|
41
|
+
@validator.valid?({}).must_equal true
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns false if the value provided is greater than the value provided" do
|
45
|
+
@validator.valid?("aaaa").must_equal false
|
46
|
+
@validator.valid?([1,2,3,4,5]).must_equal false
|
47
|
+
@validator.valid?({a: 1, b: 2, c: 3, d: 4}).must_equal false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
33
51
|
|
34
52
|
|
35
53
|
describe DuckHunt::Validators::LessThanOrEqualTo, "error message" do
|
@@ -29,7 +29,26 @@ describe DuckHunt::Validators::LessThan, "Validation" do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
describe DuckHunt::Validators::LessThan, "Validation (length check)" do
|
33
|
+
before do
|
34
|
+
@validator = DuckHunt::Validators::LessThan.new(3)
|
35
|
+
end
|
32
36
|
|
37
|
+
it "returns true if the value provided is less than the value given" do
|
38
|
+
@validator.valid?("aa").must_equal true
|
39
|
+
@validator.valid?([1]).must_equal true
|
40
|
+
@validator.valid?({}).must_equal true
|
41
|
+
@validator.valid?("").must_equal true
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns false if the value provided is greater than the value provided" do
|
45
|
+
@validator.valid?("aaa").must_equal false
|
46
|
+
@validator.valid?([1,2,3]).must_equal false
|
47
|
+
@validator.valid?("aaaa").must_equal false
|
48
|
+
@validator.valid?([1,2,3,4,5]).must_equal false
|
49
|
+
@validator.valid?({a: 1, b: 2, c: 3, d: 4}).must_equal false
|
50
|
+
end
|
51
|
+
end
|
33
52
|
|
34
53
|
describe DuckHunt::Validators::LessThan, "error message" do
|
35
54
|
it "should have the correct error message based on the value provided" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duck-hunt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Cannon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|