apireaper 1.0.3 → 1.0.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/.gitlab-ci.yml +20 -0
- data/lib/apireaper/checker.rb +1 -0
- data/lib/apireaper/cli.rb +5 -0
- data/lib/apireaper/version.rb +1 -1
- data/spec/apireaper/checker_spec.rb +20 -9
- data/spec/apireaper/cli_spec.rb +6 -0
- data/spec/apireaper/stubs/servers_stubs.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29bc9a339a8af1746c906a1e63cf961c741b2a77
|
4
|
+
data.tar.gz: 72681e2586461945d90b06d7dff4975a64db4b05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaf4aa0e487112f4dd53567fb26e502e67f91e3222e5a4cbd6dd94a6d031a5c626583d63a538db14b606d0a8235e976e5e48eaddb0eec0de6303c00baa62c00a
|
7
|
+
data.tar.gz: a3c18e4494ec989430440f951986c8adb979938a0afe1205e99d95fcbb59d0fff0d08d7c0f6084564b1ff8b16581f2c36e46b2ae3338743a0ad9c389436d95de
|
data/.gitlab-ci.yml
CHANGED
@@ -50,3 +50,23 @@ pages:
|
|
50
50
|
expire_in: 30 days
|
51
51
|
only:
|
52
52
|
- develop
|
53
|
+
|
54
|
+
gem_build:
|
55
|
+
tags:
|
56
|
+
- docker
|
57
|
+
image: yueyehua/debian-ruby
|
58
|
+
stage: build
|
59
|
+
script:
|
60
|
+
- gem build apireaper.gemspec
|
61
|
+
only:
|
62
|
+
- master
|
63
|
+
|
64
|
+
gem_push:
|
65
|
+
tags:
|
66
|
+
- docker
|
67
|
+
image: yueyehua/debian-ruby
|
68
|
+
stage: deploy
|
69
|
+
script:
|
70
|
+
- gem push apireaper-*.gem
|
71
|
+
only:
|
72
|
+
- master
|
data/lib/apireaper/checker.rb
CHANGED
data/lib/apireaper/cli.rb
CHANGED
@@ -51,6 +51,11 @@ module APIReaper
|
|
51
51
|
aliases: ['-F'],
|
52
52
|
desc: 'Data structure description as formated schema in local file'
|
53
53
|
)
|
54
|
+
option(
|
55
|
+
:outfile,
|
56
|
+
aliases: ['-o'],
|
57
|
+
desc: 'Write the response body to output file.'
|
58
|
+
)
|
54
59
|
option(
|
55
60
|
:quiet,
|
56
61
|
aliases: ['-q'],
|
data/lib/apireaper/version.rb
CHANGED
@@ -28,29 +28,40 @@ end
|
|
28
28
|
describe APIReaper::Checker do # rubocop:disable Metrics/BlockLength
|
29
29
|
context 'check post http://api.test.yueyehua.net/ -h k:v -d k=v' do
|
30
30
|
it 'requests an API and test the response body without defined schema.' do
|
31
|
-
expect { start(self) }.to output(print_out(
|
31
|
+
expect { start(self) }.to output(print_out(204)).to_stdout
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
schema_file = 'spec/files/schema'
|
36
|
-
|
37
|
-
context "check post http://api.test.yueyehua.net/ #{
|
36
|
+
opts204r1 = "-h k:v -d k=v -F #{schema_file}"
|
37
|
+
context "check post http://api.test.yueyehua.net/ #{opts204r1}" do
|
38
38
|
it 'requests an API and test the response body with schema file.' do
|
39
|
-
expect { start(self) }.to output(print_out(
|
39
|
+
expect { start(self) }.to output(print_out(204)).to_stdout
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
schema = File.read(schema_file)
|
44
|
-
|
45
|
-
context "check post http://api.test.yueyehua.net/ #{
|
44
|
+
opts204r2 = "-h k:v -d k=v -S #{schema}"
|
45
|
+
context "check post http://api.test.yueyehua.net/ #{opts204r2}" do
|
46
46
|
it 'requests an API and test the response body with a schema as option.' do
|
47
|
-
expect { start(self) }.to output(print_out(
|
47
|
+
expect { start(self) }.to output(print_out(204)).to_stdout
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
body = 'spec/files/body'
|
52
|
+
test = 'test-outfile'
|
53
|
+
out204r3 = "-h k:v -d k=v -o #{test}"
|
54
|
+
context "check post http://api.test.yueyehua.net/ #{out204r3}" do
|
55
|
+
it 'requests an API and test the response body and save it to file.' do
|
56
|
+
expect { start(self) }.to output(print_out(204)).to_stdout
|
57
|
+
expect { print File.read(test) }.to output(File.read(body)).to_stdout
|
58
|
+
File.delete(test)
|
48
59
|
end
|
49
60
|
end
|
50
61
|
|
51
62
|
schema_file = 'spec/files/schema'
|
52
|
-
|
53
|
-
context "check post http://api.fail.yueyehua.net/ #{
|
63
|
+
opts205 = "-h k:v -d k=v -q -F #{schema_file}"
|
64
|
+
context "check post http://api.fail.yueyehua.net/ #{opts205}" do
|
54
65
|
it 'requests an API and test the response body with wrong schema file.' do
|
55
66
|
expect { start(self) }.to raise_error(SystemExit)
|
56
67
|
end
|
data/spec/apireaper/cli_spec.rb
CHANGED
@@ -24,6 +24,12 @@ describe APIReaper::CLI do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
context 'check post http://api.test.yueyehua.net/ -s' do
|
28
|
+
it 'Runs the simulation mode and do nothing.' do
|
29
|
+
expect { start(self) }.to output('').to_stdout
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
27
33
|
context 'notexistingcmd' do
|
28
34
|
it 'is an unknown command and does nothing.' do
|
29
35
|
out = "Could not find command \"notexistingcmd\".\n"
|
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
require 'spec_helper'
|
18
18
|
|
19
|
-
def
|
19
|
+
def read_file(file)
|
20
20
|
dir = File.dirname(__FILE__)
|
21
21
|
File.read(File.join(dir, '..', '..', 'files', file))
|
22
22
|
end
|
@@ -41,11 +41,11 @@ RSpec.configure do |config|
|
|
41
41
|
# requests an API and test the response body
|
42
42
|
stub_request(:post, 'http://api.test.yueyehua.net/')
|
43
43
|
.with('body' => { 'k' => 'v' }, 'headers' => { 'k' => 'v' })
|
44
|
-
.to_return('status' =>
|
44
|
+
.to_return('status' => 204, 'body' => read_file('body'), 'headers' => {})
|
45
45
|
# requests an API and test the response body with wrong schema file
|
46
46
|
stub_request(:post, 'http://api.fail.yueyehua.net/')
|
47
47
|
.with('body' => { 'k' => 'v' }, 'headers' => { 'k' => 'v' })
|
48
|
-
.to_return('status' =>
|
48
|
+
.to_return('status' => 205, 'body' => read_file('fail'), 'headers' => {})
|
49
49
|
# requests an API and receive 404 status code
|
50
50
|
stub_request(:post, 'http://api.fail.yueyehua.net/')
|
51
51
|
.with('body' => { 'l' => 'w' }, 'headers' => { 'l' => 'w' })
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apireaper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Delaplace
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|