apireaper 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0d9292818540aacf4fdefbf8056dc33d8a78377
4
- data.tar.gz: 0d6b6b0a1b5ecd4a7cc588b477e981497ae0b896
3
+ metadata.gz: 29bc9a339a8af1746c906a1e63cf961c741b2a77
4
+ data.tar.gz: 72681e2586461945d90b06d7dff4975a64db4b05
5
5
  SHA512:
6
- metadata.gz: 505b5085c1481b2e6dba040533564c3838793829c17e3d440421e74522573c74df3c7dd8619f33db4ff0de6cbc5836b621372a2e92ab732efb673dfa2c5a62bb
7
- data.tar.gz: ddfee6972c6b8f097a735fdf31af8ecb00f0845c2e85a457c3f477f96958fc8e659a5160f90cc925c2c5c1dc4a77bf88fa673ffdb1783b371700e9063220121a
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
@@ -34,6 +34,7 @@ module APIReaper
34
34
  res = @requester.request
35
35
  check_response_code(res.code)
36
36
  check_data_structure(res.body)
37
+ File.write(@opts['outfile'], res.body) unless @opts['outfile'].nil?
37
38
  puts 'All checks passed' unless @opts['quiet']
38
39
  end
39
40
 
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'],
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module APIReaper
19
- VERSION = '1.0.3'.freeze
19
+ VERSION = '1.0.4'.freeze
20
20
  end
@@ -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(203)).to_stdout
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
- opts203r1 = "-h k:v -d k=v -F #{schema_file}"
37
- context "check post http://api.test.yueyehua.net/ #{opts203r1}" do
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(203)).to_stdout
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
- opts203r2 = "-h k:v -d k=v -S #{schema}"
45
- context "check post http://api.test.yueyehua.net/ #{opts203r2}" do
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(203)).to_stdout
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
- opts204 = "-h k:v -d k=v -q -F #{schema_file}"
53
- context "check post http://api.fail.yueyehua.net/ #{opts204}" do
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
@@ -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 body_file(file)
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' => 203, 'body' => body_file('body'), 'headers' => {})
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' => 204, 'body' => body_file('fail'), 'headers' => {})
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.3
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-14 00:00:00.000000000 Z
11
+ date: 2017-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler