client-api 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78a0f98ad38e54b48affccbc678e5d464e37f641c432010f97c9047b8dc93d1b
4
- data.tar.gz: fddd90c9c56f78a1cf035c0217e7ee7f4220f9f253f7adfd156d0c0abf803095
3
+ metadata.gz: 0b3b35e20afa816b35cd7365835102d7f6cc8c03ef3c04b32c782fa2068de357
4
+ data.tar.gz: a7172042a889d3015d49873127c26e7a4511b0aa41e2e98220d0b6d909807569
5
5
  SHA512:
6
- metadata.gz: 04570d6f2de70cc546399075405c4627b5b54d6a3e9592700ebbb78094053457d1e426a078a256d0d4a0b1b3239376c1d2b5d82d2cccf4a9c19f919ba93dcb63
7
- data.tar.gz: c2967504a40cff42de718ed67dbfa9d3949156820234951818d07239f63095aa17e4dac2f25b61e63153b052dd455b2b2fced280498ddf321dfd1972b1161ff7
6
+ metadata.gz: da607fde080b2b1cf7dabb8b109ef3eeb2a6d809742acf41b15bb6aca7a017d927e205d421b3aa8bd80e96df54268e024927d28ad33ff479093f7919b936ca60
7
+ data.tar.gz: a3121f16f643cb0663f4b16d82cdcb54ce070bc5dd147d9b3de6e8e12b741f7965cb14e55b0cb40f698cbd88f6e80a4c2dbd8cea2a175ed1327aea5f5356de34
@@ -1,4 +1,5 @@
1
1
  require "json-schema"
2
+ require "byebug"
2
3
 
3
4
  module ClientApi
4
5
 
@@ -7,7 +8,7 @@ module ClientApi
7
8
  raise_error('key (or) operator is not given!') if data[:key].nil? && data[:operator].nil?
8
9
  raise_error('value (or) type is not given!') if data[:value].nil? && data[:type].nil?
9
10
 
10
- @resp = res
11
+ @resp = JSON.parse(res.to_json)
11
12
  key = data[:key].split("->")
12
13
 
13
14
  key.map do |method|
@@ -27,7 +28,7 @@ module ClientApi
27
28
  # datatype validation
28
29
  if (type == 'boolean') || (type == 'bool') && value.nil?
29
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"}
30
- else
31
+ elsif (type != nil) && (value != nil)
31
32
  expect(datatype(type, value)).to eq(@resp.class), lambda {"[key]: \"#{data[:key]}\"".blue + "\n datatype shouldn't be \n[type]: \"#{data[:type]}\"\n"}
32
33
  end
33
34
 
@@ -38,9 +39,23 @@ module ClientApi
38
39
  # datatype validation
39
40
  if (type == 'boolean') || (type == 'bool') && value.nil?
40
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"}
41
- else
42
+ elsif (type != nil) && (value != nil)
42
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"}
43
44
  end
45
+
46
+ when '>', '>=', '<', '<=', 'greater than', 'greater than or equal to', 'less than', 'less than or equal to', 'lesser than', 'lesser than or equal to'
47
+
48
+ message = 'is not greater than (or) equal to' if operator == '>=' || operator == 'greater than or equal to'
49
+ message = 'is not greater than' if operator == '>' || operator == 'greater than'
50
+ message = 'is not lesser than' if operator == '<=' || operator == 'less than or equal to'
51
+ message = 'is not lesser than (or) equal to' if operator == '<' || operator == 'less than' || operator == 'lesser than'
52
+
53
+ # value validation
54
+ 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
+
56
+ # datatype validation
57
+ 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
58
+
44
59
  else
45
60
  raise_error('operator not matching')
46
61
  end
@@ -149,7 +164,6 @@ module ClientApi
149
164
  end
150
165
 
151
166
  if @overall.count(true) == value.count
152
- return
153
167
  else
154
168
  expect(value).to eq(@resp)
155
169
  end
@@ -1,3 +1,3 @@
1
1
  module ClientApi
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.2.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: client-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Prashanth Sams