virtuatable 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/virtuatable/builders/helpers/environment.rb +2 -1
- data/lib/virtuatable/specs.rb +90 -0
- data/lib/virtuatable/version.rb +1 -1
- data/lib/virtuatable.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cd86829736be01f12a1db35c85f32513ad867d7d1da90653e5ea72daaab4b6c
|
4
|
+
data.tar.gz: 91c4df3d59ad15bbd01863dda00b579dbfe036c784c1032811e38ad2be74afe0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a898038115a0536877da85e88106e41ddba528980ef1e5cd3ae19c2a6781ecf2e3ab91b63ef63de9a061cdcaf6409ad8a0fe7d2a3d791ef0e0244480cb316535
|
7
|
+
data.tar.gz: db2d41f21c9da67b47394643485df87f90c8b0d8b9727ab0d3a8098ca84e4fc811cd47d2db264b2bb58b56413360609d97035818a2c867bda9728581e75afcee
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Virtuatable
|
2
|
+
# This module holds all the logic for the specs tools for all micro services (shared examples and other things).
|
3
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
4
|
+
module Specs
|
5
|
+
|
6
|
+
@@declared = false
|
7
|
+
|
8
|
+
# Includes all the shared examples you could need, describing the basic behaviour of a route.
|
9
|
+
def self.include_shared_examples
|
10
|
+
if !@@declared
|
11
|
+
RSpec.shared_examples 'a route' do |_verb, _path|
|
12
|
+
let(:verb) { _verb }
|
13
|
+
let(:path) { _path }
|
14
|
+
|
15
|
+
def do_request(parameters)
|
16
|
+
public_send verb.to_sym, path, parameters
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'common errors' do
|
20
|
+
describe 'bad request errors' do
|
21
|
+
describe 'no token error' do
|
22
|
+
before do
|
23
|
+
do_request(app_key: 'test_key')
|
24
|
+
end
|
25
|
+
it 'Raises a bad request (400) error when the parameters don\'t contain the token of the gateway' do
|
26
|
+
expect(last_response.status).to be 400
|
27
|
+
end
|
28
|
+
it 'returns the correct response if the parameters do not contain a gateway token' do
|
29
|
+
expect(last_response.body).to include_json(
|
30
|
+
status: 400,
|
31
|
+
field: 'token',
|
32
|
+
error: 'required'
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
describe 'no application key error' do
|
37
|
+
before do
|
38
|
+
do_request({token: 'test_token'})
|
39
|
+
end
|
40
|
+
it 'Raises a bad request (400) error when the parameters don\'t contain the application key' do
|
41
|
+
expect(last_response.status).to be 400
|
42
|
+
end
|
43
|
+
it 'returns the correct response if the parameters do not contain a gateway token' do
|
44
|
+
expect(last_response.body).to include_json(
|
45
|
+
status: 400,
|
46
|
+
field: 'app_key',
|
47
|
+
error: 'required'
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
describe 'not_found errors' do
|
53
|
+
describe 'application not found' do
|
54
|
+
before do
|
55
|
+
do_request({token: 'test_token', app_key: 'another_key'})
|
56
|
+
end
|
57
|
+
it 'Raises a not found (404) error when the key doesn\'t belong to any application' do
|
58
|
+
expect(last_response.status).to be 404
|
59
|
+
end
|
60
|
+
it 'returns the correct response if the parameters do not contain a gateway token' do
|
61
|
+
expect(last_response.body).to include_json(
|
62
|
+
status: 404,
|
63
|
+
field: 'app_key',
|
64
|
+
error: 'unknown'
|
65
|
+
)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
describe 'gateway not found' do
|
69
|
+
before do
|
70
|
+
do_request({token: 'other_token', app_key: 'test_key'})
|
71
|
+
end
|
72
|
+
it 'Raises a not found (404) error when the gateway does\'nt exist' do
|
73
|
+
expect(last_response.status).to be 404
|
74
|
+
end
|
75
|
+
it 'returns the correct body when the gateway doesn\'t exist' do
|
76
|
+
expect(last_response.body).to include_json(
|
77
|
+
status: 404,
|
78
|
+
field: 'token',
|
79
|
+
error: 'unknown'
|
80
|
+
)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
@@declared = true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/lib/virtuatable/version.rb
CHANGED
data/lib/virtuatable.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: virtuatable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Courtois
|
@@ -384,6 +384,7 @@ files:
|
|
384
384
|
- lib/virtuatable/helpers/gateways.rb
|
385
385
|
- lib/virtuatable/helpers/routes.rb
|
386
386
|
- lib/virtuatable/helpers/sessions.rb
|
387
|
+
- lib/virtuatable/specs.rb
|
387
388
|
- lib/virtuatable/version.rb
|
388
389
|
homepage: https://rubygems.org/gems/arkaan
|
389
390
|
licenses:
|