client-api 0.2.4 → 0.2.5
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/lib/client-api/validator.rb +28 -6
- data/lib/client-api/version.rb +1 -1
- 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: 6dbc0b53689ca77ae651de925fe7c51c36e26a92295e6a71803b9a32627dfaca
|
4
|
+
data.tar.gz: 19f258c46f7587bc2b1b23429e0f0ca47e0660ddbcbc4b9c53eb33d559ccf87e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e359917c7003610f039b651eda0a5345e1c8bdd7fadb08ea504d84b7daad7d945da32efee9fa280eeeb5523e8bb79dda0f3c1887fdee2edd55c1a488f7c38e3
|
7
|
+
data.tar.gz: f837b44b36edba5990a7e72b37f193612de313bff0107963384f49d5fbaf90c71e8443435cd7c504b4f2354c67c741bda9a14ed1d4d70eee3358f08d1407f8f8
|
data/lib/client-api/validator.rb
CHANGED
@@ -18,7 +18,7 @@ module ClientApi
|
|
18
18
|
|
19
19
|
value ||= data[:value]
|
20
20
|
operator = data[:operator]
|
21
|
-
type
|
21
|
+
type ||= data[:type]
|
22
22
|
|
23
23
|
case operator
|
24
24
|
when '=', '==', 'eql?', 'equal', 'equal?'
|
@@ -26,9 +26,9 @@ module ClientApi
|
|
26
26
|
expect(value).to eq(@resp), lambda {"[key]: \"#{data[:key]}\"".blue + "\n didn't match \n[value]: \"#{data[:value]}\"\n"} if value != nil
|
27
27
|
|
28
28
|
# datatype validation
|
29
|
-
if (type == 'boolean') || (type == 'bool')
|
29
|
+
if (type == 'boolean') || (type == 'bool')
|
30
30
|
expect(%w[TrueClass, FalseClass].any? {|bool| bool.include? @resp.class.to_s}).to eq(true), lambda {"[key]: \"#{data[:key]}\"".blue + "\n datatype shouldn't be \n[type]: \"#{data[:type]}\"\n"}
|
31
|
-
elsif (type !=
|
31
|
+
elsif ((type != 'boolean') || (type != 'bool')) && (type != nil)
|
32
32
|
expect(datatype(type, value)).to eq(@resp.class), lambda {"[key]: \"#{data[:key]}\"".blue + "\n datatype shouldn't be \n[type]: \"#{data[:type]}\"\n"}
|
33
33
|
end
|
34
34
|
|
@@ -37,9 +37,9 @@ module ClientApi
|
|
37
37
|
expect(value).not_to eq(@resp), lambda {"[key]: \"#{data[:key]}\"".blue + "\n didn't match \n[value]: \"#{data[:value]}\"\n"} if value != nil
|
38
38
|
|
39
39
|
# datatype validation
|
40
|
-
if (type == 'boolean') || (type == 'bool')
|
40
|
+
if (type == 'boolean') || (type == 'bool')
|
41
41
|
expect(%w[TrueClass, FalseClass].any? {|bool| bool.include? @resp.class.to_s}).not_to eq(true), lambda {"[key]: \"#{data[:key]}\"".blue + "\n datatype shouldn't be \n[type]: \"#{data[:type]}\"\n"}
|
42
|
-
elsif (type !=
|
42
|
+
elsif ((type != 'boolean') || (type != 'bool')) && (type != nil)
|
43
43
|
expect(datatype(type, value)).not_to eq(@resp.class), lambda {"[key]: \"#{data[:key]}\"".blue + "\n datatype shouldn't be \n[type]: \"#{data[:type]}\"\n"}
|
44
44
|
end
|
45
45
|
|
@@ -53,7 +53,29 @@ module ClientApi
|
|
53
53
|
expect(@resp.to_i.public_send(operator, value)).to eq(true), "[key]: \"#{data[:key]}\"".blue + "\n #{message} \n[value]: \"#{data[:value]}\"\n" if value != nil
|
54
54
|
|
55
55
|
# datatype validation
|
56
|
-
expect(datatype(type, value)).to eq(@resp.class), lambda {"[key]: \"#{data[:key]}\"".blue + "\n datatype shouldn't be \n[type]: \"#{data[:type]}\"\n"}
|
56
|
+
expect(datatype(type, value)).to eq(@resp.class), lambda {"[key]: \"#{data[:key]}\"".blue + "\n datatype shouldn't be \n[type]: \"#{data[:type]}\"\n"} if type != nil
|
57
|
+
|
58
|
+
when 'contains', 'has', 'contains?', 'has?', 'include', 'include?'
|
59
|
+
# value validation
|
60
|
+
expect(@resp.to_s).to include(value.to_s), lambda {"[key]: \"#{data[:key]} => #{@resp}\"".blue + "\n not contains \n[value]: \"#{data[:value]}\"\n"} if value != nil
|
61
|
+
|
62
|
+
# datatype validation
|
63
|
+
if (type == 'boolean') || (type == 'bool')
|
64
|
+
expect(%w[TrueClass, FalseClass].any? {|bool| bool.include? @resp.class.to_s}).to eq(true), lambda {"[key]: \"#{data[:key]}\"".blue + "\n datatype shouldn't be \n[type]: \"#{data[:type]}\"\n"}
|
65
|
+
elsif ((type != 'boolean') || (type != 'bool')) && (type != nil)
|
66
|
+
expect(datatype(type, value)).to eq(@resp.class), lambda {"[key]: \"#{data[:key]}\"".blue + "\n datatype shouldn't be \n[type]: \"#{data[:type]}\"\n"}
|
67
|
+
end
|
68
|
+
|
69
|
+
when 'not contains', '!contains', 'not include', '!include'
|
70
|
+
# value validation
|
71
|
+
expect(@resp.to_s).not_to include(value.to_s), lambda {"[key]: \"#{data[:key]} => #{@resp}\"".blue + "\n should not contain \n[value]: \"#{data[:value]}\"\n"} if value != nil
|
72
|
+
|
73
|
+
# datatype validation
|
74
|
+
if (type == 'boolean') || (type == 'bool')
|
75
|
+
expect(%w[TrueClass, FalseClass].any? {|bool| bool.include? @resp.class.to_s}).not_to eq(true), lambda {"[key]: \"#{data[:key]}\"".blue + "\n datatype shouldn't be \n[type]: \"#{data[:type]}\"\n"}
|
76
|
+
elsif ((type != 'boolean') || (type != 'bool')) && (type != nil)
|
77
|
+
expect(datatype(type, value)).not_to eq(@resp.class), lambda {"[key]: \"#{data[:key]}\"".blue + "\n datatype shouldn't be \n[type]: \"#{data[:type]}\"\n"}
|
78
|
+
end
|
57
79
|
|
58
80
|
else
|
59
81
|
raise('operator not matching')
|
data/lib/client-api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: client-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Prashanth Sams
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|