client-api 0.2.3 → 0.2.4
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/base.rb +9 -0
- data/lib/client-api/validator.rb +29 -3
- data/lib/client-api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c02b29aa08f24e7cab407632413b695ff29296ff02280ed37bcfb7582f7c4c42
|
4
|
+
data.tar.gz: 275becbf9891f8958efa1a9aa4a33d86e7308094a3b4370a7d60c3c9fb0acd27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8724c2f11d6635b770c893a7db95da760d8920516c67613449c4af44dcc7146135bd8e50c0d8199ee99b2c1a7b9b1b3dc7c493d06c9dbee57fed85d2d8d0470a
|
7
|
+
data.tar.gz: c945105f129f17a51084b2b648116e5fd134df7842bc0ad8d3a43e038a976ddf425005bf27dfea12cd0a38dc2e0249902cfc6bd2b407a33f8900f20354990865
|
data/lib/client-api/base.rb
CHANGED
@@ -64,6 +64,11 @@ module ClientApi
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
def response_headers
|
68
|
+
resp_headers = {}
|
69
|
+
@output.response.each { |key, value| resp_headers.merge!(key.to_s => value.to_s) }
|
70
|
+
end
|
71
|
+
|
67
72
|
def message
|
68
73
|
@output.message
|
69
74
|
end
|
@@ -73,6 +78,10 @@ module ClientApi
|
|
73
78
|
|
74
79
|
$logger.debug("Response code == #{@output.code.to_i}")
|
75
80
|
$logger.debug("Response body == #{res_body}")
|
81
|
+
|
82
|
+
log_headers = {}
|
83
|
+
@output.response.each { |key, value| log_headers.merge!(key.to_s => value.to_s) }
|
84
|
+
$logger.debug("Response headers == #{log_headers}")
|
76
85
|
$logger.debug("=====================================================================================")
|
77
86
|
end
|
78
87
|
|
data/lib/client-api/validator.rb
CHANGED
@@ -4,8 +4,9 @@ module ClientApi
|
|
4
4
|
|
5
5
|
def validate(res, *options)
|
6
6
|
options.map do |data|
|
7
|
-
|
8
|
-
|
7
|
+
raise('key is not given!') if data[:key].nil?
|
8
|
+
raise('operator is not given!') if data[:operator].nil?
|
9
|
+
raise('value (or) type is not given!') if data[:value].nil? && data[:type].nil?
|
9
10
|
|
10
11
|
@resp = JSON.parse(res.to_json)
|
11
12
|
key = data[:key].split("->")
|
@@ -55,7 +56,7 @@ module ClientApi
|
|
55
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
|
56
57
|
|
57
58
|
else
|
58
|
-
|
59
|
+
raise('operator not matching')
|
59
60
|
end
|
60
61
|
end
|
61
62
|
end
|
@@ -65,6 +66,31 @@ module ClientApi
|
|
65
66
|
expect(expected_schema).to eq(true)
|
66
67
|
end
|
67
68
|
|
69
|
+
def validate_headers(res, *options)
|
70
|
+
options.map do |data|
|
71
|
+
raise('key is not given!') if data[:key].nil?
|
72
|
+
raise('operator is not given!') if data[:operator].nil?
|
73
|
+
raise('value is not given!') if data[:value].nil?
|
74
|
+
|
75
|
+
@resp_header = JSON.parse(res.to_json)
|
76
|
+
|
77
|
+
key = data[:key]
|
78
|
+
value = data[:value]
|
79
|
+
operator = data[:operator]
|
80
|
+
|
81
|
+
case operator
|
82
|
+
when '=', '==', 'eql?', 'equal', 'equal?'
|
83
|
+
expect(value).to eq(@resp_header[key][0]), lambda {"\"#{key}\" => \"#{value}\"".blue + "\n didn't match \n\"#{key}\" => \"#{@resp_header[key][0]}\"\n"}
|
84
|
+
|
85
|
+
when '!', '!=', '!eql?', 'not equal', '!equal?'
|
86
|
+
expect(value).not_to eq(@resp_header[key][0]), lambda {"\"#{key}\" => \"#{value}\"".blue + "\n shouldn't match \n\"#{key}\" => \"#{@resp_header[key][0]}\"\n"}
|
87
|
+
|
88
|
+
else
|
89
|
+
raise('operator not matching')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
68
94
|
def datatype(type, value)
|
69
95
|
if (type.downcase == 'string') || (type.downcase.== 'str')
|
70
96
|
String
|
data/lib/client-api/version.rb
CHANGED