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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e83a3b44d7c09021e9473a718dbe41a359ca2e606cb4aeed705186c67f419ed0
4
- data.tar.gz: a6963371ad99552cecb8b7a69f5a15d8bcade5115b14924e216b9b9dae26c5b6
3
+ metadata.gz: 75d1dd61f15a97d225e5c9536b1af5146983565c57ac7de01d1dac4c1b7b679b
4
+ data.tar.gz: cc7eb8aa77af9aa931ee5431da737415b407ae78eac74cfddb0ec79d5ecc3441
5
5
  SHA512:
6
- metadata.gz: 021500d3fbb1bb1d22c5ec8579ec1d556a868f394e92684f8e5d3217308abfe28270b0d4669d36f6ecdedc204fa81e0143c0af9fe78ad3bd2eac5b8539158b15
7
- data.tar.gz: 93f9948d65a24c6a6a2c4ffed665f7325bb7c09aa50c4ac53de25cdcc5f151d05d50e5329d55153dc95042d0bb4d187b9005bcc0fe57b4d2da5da9700937adec
6
+ metadata.gz: 351f223a9c7744958224e809aacaae26c87dc5e21489a29d55b41e5a0cd8c27870ff6716ad1f4b63353c93bf5f5b1bcfea707cbd97db8b2b9ba8a8df2aecc49e
7
+ data.tar.gz: d0c47052a4073c6133ec3c63967b25b29f1f7c185fa9906b4830fe15abf2e8c1b01eafdfecf943cf445b691b1d7a64378aa89fe34652192ff7d74b43a1018a4a
@@ -8,7 +8,11 @@ module DuckHunt
8
8
  end
9
9
 
10
10
  def valid?(value)
11
- return value > @value
11
+ if value.respond_to?(:length)
12
+ return value.length > @value
13
+ else
14
+ return value > @value
15
+ end
12
16
  end
13
17
 
14
18
  def error_message
@@ -8,7 +8,11 @@ module DuckHunt
8
8
  end
9
9
 
10
10
  def valid?(value)
11
- return value >= @value
11
+ if value.respond_to?(:length)
12
+ return value.length >= @value
13
+ else
14
+ return value >= @value
15
+ end
12
16
  end
13
17
 
14
18
  def error_message
@@ -8,7 +8,11 @@ module DuckHunt
8
8
  end
9
9
 
10
10
  def valid?(value)
11
- return value < @value
11
+ if value.respond_to?(:length)
12
+ return value.length < @value
13
+ else
14
+ return value < @value
15
+ end
12
16
  end
13
17
 
14
18
  def error_message
@@ -8,7 +8,11 @@ module DuckHunt
8
8
  end
9
9
 
10
10
  def valid?(value)
11
- return value <= @value
11
+ if value.respond_to?(:length)
12
+ return value.length <= @value
13
+ else
14
+ return value <= @value
15
+ end
12
16
  end
13
17
 
14
18
  def error_message
@@ -1,3 +1,3 @@
1
1
  module DuckHunt
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -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.new("3.4")
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.new("3.4")
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.new("3.4")
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.6
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: 2019-04-09 00:00:00.000000000 Z
11
+ date: 2020-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest