client-api 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/client-api/request.rb +7 -2
- data/lib/client-api/validator.rb +46 -5
- data/lib/client-api/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d151a6541ddc08498bd506b21fd8578a436d2b2745aa222e962197cd301079eb
|
4
|
+
data.tar.gz: c8554dae87838761e44411c182621cb00aeb98845bf78d3bcb087848005dfe8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 459b30e070200f9770b9de1f510969d83a90730429d18e71df2c9f3858d64761b36ff16d9146adad5a7058dbd25189a898acaef8f338ee3b2245295284e8a1a6
|
7
|
+
data.tar.gz: b2b6943c386cd7985ad2794fd1bce6c1794001445dd9a910af56befe6862d2532296ae847764c04357a45849635bde07569384e095e7743e974b22e193655191
|
data/lib/client-api/request.rb
CHANGED
@@ -99,8 +99,13 @@ module ClientApi
|
|
99
99
|
def header(options = {})
|
100
100
|
mod_headers = options[:headers] || {}
|
101
101
|
authorization = basic_encode(:username => basic_auth['Username'], :password => basic_auth['Password'])
|
102
|
-
headers
|
103
|
-
|
102
|
+
if headers == nil || headers == ""
|
103
|
+
@headers = {}
|
104
|
+
else
|
105
|
+
@headers = headers
|
106
|
+
end
|
107
|
+
@headers['Authorization'] = authorization if authorization != "Basic Og=="
|
108
|
+
@headers.merge(mod_headers)
|
104
109
|
end
|
105
110
|
|
106
111
|
def pre_logger(options = {})
|
data/lib/client-api/validator.rb
CHANGED
@@ -6,7 +6,7 @@ module ClientApi
|
|
6
6
|
options.map do |data|
|
7
7
|
raise('key is not given!') if data[:key].nil?
|
8
8
|
raise('operator is not given!') if data[:operator].nil?
|
9
|
-
raise('value
|
9
|
+
raise('value / type / size is not given!') if data[:value].nil? && data[:type].nil? && data[:size].nil?
|
10
10
|
|
11
11
|
@resp = JSON.parse(res.to_json)
|
12
12
|
key = data[:key].split("->")
|
@@ -19,9 +19,10 @@ module ClientApi
|
|
19
19
|
value ||= data[:value]
|
20
20
|
operator = data[:operator]
|
21
21
|
type ||= data[:type]
|
22
|
+
size ||= data[:size]
|
22
23
|
|
23
24
|
case operator
|
24
|
-
when '=', '==', 'eql?', 'equal', 'equal?'
|
25
|
+
when '=', '==', 'eql', 'eql?', 'equal', 'equal?'
|
25
26
|
# value validation
|
26
27
|
expect(value).to eq(@resp), lambda {"[key]: \"#{data[:key]}\"".blue + "\n didn't match \n[value]: \"#{data[:value]}\"\n"} if value != nil
|
27
28
|
|
@@ -32,7 +33,15 @@ module ClientApi
|
|
32
33
|
expect(datatype(type, value)).to eq(@resp.class), lambda {"[key]: \"#{data[:key]}\"".blue + "\n datatype shouldn't be \n[type]: \"#{data[:type]}\"\n"}
|
33
34
|
end
|
34
35
|
|
35
|
-
|
36
|
+
if size != nil
|
37
|
+
begin
|
38
|
+
expect(size).to eq(@resp.count), lambda {"[key]: \"#{data[:key]}\"".blue + "\n" + "size didn't match" + "\n\n" + "[ actual size ]: #{@resp.count}" + "\n" + "[expected size]: #{size}".green}
|
39
|
+
rescue NoMethodError
|
40
|
+
expect(size).to eq(0), lambda {"[key]: \"#{data[:key]}\"".blue + "\n" + "size didn't match" + "\n\n" + "[ actual size ]: 0" + "\n" + "[expected size]: #{size}".green}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
when '!', '!=', '!eql', '!eql?', 'not eql', 'not equal', '!equal?'
|
36
45
|
# value validation
|
37
46
|
expect(value).not_to eq(@resp), lambda {"[key]: \"#{data[:key]}\"".blue + "\n didn't match \n[value]: \"#{data[:value]}\"\n"} if value != nil
|
38
47
|
|
@@ -43,11 +52,19 @@ module ClientApi
|
|
43
52
|
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
53
|
end
|
45
54
|
|
55
|
+
if size != nil
|
56
|
+
begin
|
57
|
+
expect(size).not_to eq(@resp.count), lambda {"[key]: \"#{data[:key]}\"".blue + "\n" + "size shouldn't match" + "\n\n" + "[ actual size ]: #{@resp.count}" + "\n" + "[size not expected]: #{size}".green}
|
58
|
+
rescue NoMethodError
|
59
|
+
expect(size).not_to eq(0), lambda {"[key]: \"#{data[:key]}\"".blue + "\n" + "size shouldn't match" + "\n\n" + "[ actual size ]: 0" + "\n" + "[size not expected]: #{size}".green}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
46
63
|
when '>', '>=', '<', '<=', 'greater than', 'greater than or equal to', 'less than', 'less than or equal to', 'lesser than', 'lesser than or equal to'
|
47
64
|
message = 'is not greater than (or) equal to' if operator == '>=' || operator == 'greater than or equal to'
|
48
65
|
message = 'is not greater than' if operator == '>' || operator == 'greater than'
|
49
|
-
message = 'is not lesser than' if operator == '<=' || operator == 'less than or equal to'
|
50
|
-
message = 'is not lesser than
|
66
|
+
message = 'is not lesser than (or) equal to' if operator == '<=' || operator == 'less than or equal to'
|
67
|
+
message = 'is not lesser than' if operator == '<' || operator == 'less than' || operator == 'lesser than'
|
51
68
|
|
52
69
|
# value validation
|
53
70
|
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
|
@@ -55,6 +72,14 @@ module ClientApi
|
|
55
72
|
# datatype validation
|
56
73
|
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
74
|
|
75
|
+
if size != nil
|
76
|
+
begin
|
77
|
+
expect(@resp.count.to_i.public_send(operator, size)).to eq(true), lambda {"[key]: \"#{data[:key]}\"".blue + "\n" + "#{message} #{size}" + "\n\n" + "[ actual size ]: #{@resp.count}" + "\n" + "expected size to be #{operator} #{size}".green}
|
78
|
+
rescue NoMethodError
|
79
|
+
expect(0.public_send(operator, size)).to eq(true), lambda {"[key]: \"#{data[:key]}\"".blue + "\n" + "#{message} #{size}" + "\n\n" + "[ actual size ]: 0" + "\n" + "expected size to be #{operator} #{size}".green}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
58
83
|
when 'contains', 'has', 'contains?', 'has?', 'include', 'include?'
|
59
84
|
# value validation
|
60
85
|
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
|
@@ -66,6 +91,14 @@ module ClientApi
|
|
66
91
|
expect(datatype(type, value)).to eq(@resp.class), lambda {"[key]: \"#{data[:key]}\"".blue + "\n datatype shouldn't be \n[type]: \"#{data[:type]}\"\n"}
|
67
92
|
end
|
68
93
|
|
94
|
+
if size != nil
|
95
|
+
begin
|
96
|
+
expect(@resp.count.to_s).to include(size.to_s), lambda {"[key]: \"#{data[:key]} => #{@resp}\"".blue + "\n"+ "size not contains #{size}"+ "\n\n" + "[ actual size ]: #{@resp.count}" + "\n" + "expected size to contain: #{size}".green}
|
97
|
+
rescue NoMethodError
|
98
|
+
expect(0.to_s).to include(size.to_s), lambda {"[key]: \"#{data[:key]} => #{@resp}\"".blue + "\n"+ "size not contains #{size}"+ "\n\n" + "[ actual size ]: 0" + "\n" + "expected size to contain: #{size}".green}
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
69
102
|
when 'not contains', '!contains', 'not include', '!include'
|
70
103
|
# value validation
|
71
104
|
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
|
@@ -77,6 +110,14 @@ module ClientApi
|
|
77
110
|
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
111
|
end
|
79
112
|
|
113
|
+
if size != nil
|
114
|
+
begin
|
115
|
+
expect(@resp.count.to_s).not_to include(size.to_s), lambda {"[key]: \"#{data[:key]} => #{@resp}\"".blue + "\n"+ "size should not contain #{size}"+ "\n\n" + "[ actual size ]: #{@resp.count}" + "\n" + "expected size not to contain: #{size}".green}
|
116
|
+
rescue NoMethodError
|
117
|
+
expect(0.to_s).not_to include(size.to_s), lambda {"[key]: \"#{data[:key]} => #{@resp}\"".blue + "\n"+ "size should not contain #{size}"+ "\n\n" + "[ actual size ]: 0" + "\n" + "expected size not to contain: #{size}".green}
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
80
121
|
else
|
81
122
|
raise('operator not matching')
|
82
123
|
end
|
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.3.
|
4
|
+
version: 0.3.1
|
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-11-
|
11
|
+
date: 2019-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,6 +134,6 @@ requirements: []
|
|
134
134
|
rubygems_version: 3.0.4
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
|
-
summary: HTTP
|
138
|
-
itself
|
137
|
+
summary: HTTP REST API client for testing application APIs based on the ruby’s RSpec
|
138
|
+
framework that binds a complete api automation framework setup within itself
|
139
139
|
test_files: []
|