apireaper 1.0.2 → 1.0.3

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
  SHA1:
3
- metadata.gz: 2b42796a8d05da4a07d24ad0618cc8e35d4e7761
4
- data.tar.gz: 939d3457d1a1ab1b21baf562adda3f78115ba047
3
+ metadata.gz: f0d9292818540aacf4fdefbf8056dc33d8a78377
4
+ data.tar.gz: 0d6b6b0a1b5ecd4a7cc588b477e981497ae0b896
5
5
  SHA512:
6
- metadata.gz: dcd488923977db3fb1009349ac09661ac34307defe6c93aef2337c776c904da5f2cdf8eb24b599fcca0ba4a5831f3d177923b3dabc54ccb7fb6670a5bcbe31ff
7
- data.tar.gz: b9b32361f123d54b3b7cd63c4c30d4a34b68bef4f88103123bd39a0fa2ce82fc000448cbd9e481da8d20a73a04625bade0de03bea8c2d5f599c8a95f3d2d3c09
6
+ metadata.gz: 505b5085c1481b2e6dba040533564c3838793829c17e3d440421e74522573c74df3c7dd8619f33db4ff0de6cbc5836b621372a2e92ab732efb673dfa2c5a62bb
7
+ data.tar.gz: ddfee6972c6b8f097a735fdf31af8ecb00f0845c2e85a457c3f477f96958fc8e659a5160f90cc925c2c5c1dc4a77bf88fa673ffdb1783b371700e9063220121a
data/lib/apireaper/cli.rb CHANGED
@@ -37,7 +37,8 @@ module APIReaper
37
37
  option(
38
38
  :data,
39
39
  aliases: ['-d'],
40
- desc: 'Set of data sent with the request'
40
+ desc: 'Set of data sent with the request. ' \
41
+ 'May be of type x_www_form_urlencoded or json'
41
42
  )
42
43
  option(
43
44
  :schema,
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module APIReaper
19
- VERSION = '1.0.2'.freeze
19
+ VERSION = '1.0.3'.freeze
20
20
  end
@@ -0,0 +1,73 @@
1
+ #
2
+ # Copyright (c) 2017 Richard Delaplace, Vente-Privee.Com
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'spec_helper'
18
+
19
+ def print_out(code)
20
+ case code
21
+ when 200, 201, 202
22
+ "Response code is valid: #{code}\n" \
23
+ "Response body is valid\n" \
24
+ "All checks passed\n"
25
+ end
26
+ end
27
+
28
+ describe APIReaper::Requester do # rubocop:disable Metrics/BlockLength
29
+ %w[delete get put].each do |method|
30
+ context "check #{method} http://api.test.yueyehua.net/ -q" do
31
+ it 'tries unimplemented commands.' do
32
+ expect { start(self) }.to raise_error(SystemExit)
33
+ end
34
+ end
35
+ end
36
+
37
+ context 'check notexistingcmd http://api.test.yueyehua.net/ -q' do
38
+ it 'tries unimplemented commands.' do
39
+ expect { start(self) }.to raise_error(SystemExit)
40
+ end
41
+ end
42
+
43
+ context 'check post http://api.test.yueyehua.net/' do
44
+ it 'requests an API without extra arguments.' do
45
+ expect { start(self) }.to output(print_out(200)).to_stdout
46
+ end
47
+ end
48
+
49
+ context 'check post http://api.test.yueyehua.net/ -h k:v' do
50
+ it 'requests an API with headers.' do
51
+ expect { start(self) }.to output(print_out(201)).to_stdout
52
+ end
53
+ end
54
+
55
+ context 'check post http://api.test.yueyehua.net/ -d 3wfk=3wfv' do
56
+ it 'requests an API with www_form type datas.' do
57
+ expect { start(self) }.to output(print_out(202)).to_stdout
58
+ end
59
+ end
60
+
61
+ opts202 = '-d "{\"jsonk\":\"jsonv\"}" -h Content-type:application/json'
62
+ context "check post http://api.test.yueyehua.net/ #{opts202}" do
63
+ it 'requests an API with json type datas.' do
64
+ expect { start(self) }.to output(print_out(203)).to_stdout
65
+ end
66
+ end
67
+
68
+ context 'check post http://api.test.yueyehua.net/ -d k@v&l:w' do
69
+ it 'requests an API with wrong type of datas.' do
70
+ expect { start(self) }.to raise_error(SystemExit)
71
+ end
72
+ end
73
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apireaper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Delaplace
@@ -147,6 +147,7 @@ files:
147
147
  - lib/apireaper/version.rb
148
148
  - spec/apireaper/checker_spec.rb
149
149
  - spec/apireaper/cli_spec.rb
150
+ - spec/apireaper/requester_spec.rb
150
151
  - spec/apireaper/stubs/servers_stubs.rb
151
152
  - spec/apireaper_spec.rb
152
153
  - spec/files/body