arkaan 0.7.28 → 0.7.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/arkaan/specs.rb +57 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09483e1d839504771cff9d137468636842e6cc09
|
4
|
+
data.tar.gz: e28e63b7218cc1b597b1049a7d0dbb639f1730be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2639f53963e11609d3d6c314b2a66005c4d7a3479fcb6433476d50c24707811692d78ab0e5f54fac157be90b87390be89a31785dfc774ce12d02f17e4c0da56
|
7
|
+
data.tar.gz: 0e61c562d4ada6bcda8113693c815fb429bad067f986e0fe5d0bd22d9313b8c0988e6bd924af9530984e8fe416b1c90a88f26744b53df336024effa70577973f
|
data/lib/arkaan/specs.rb
CHANGED
@@ -5,8 +5,64 @@ module Arkaan
|
|
5
5
|
|
6
6
|
# Includes all the shared examples you could need, describing the basic behaviour of a route.
|
7
7
|
def self.include_shared_examples
|
8
|
-
RSpec.shared_examples 'route' do |
|
8
|
+
RSpec.shared_examples 'route' do |_verb, _path|
|
9
|
+
let(:verb) { _verb }
|
10
|
+
let(:path) { _path }
|
9
11
|
|
12
|
+
def do_request(parameters)
|
13
|
+
public_send verb.to_sym, path, ['get', 'delete'].include?(verb) ? parameters : parameters.to_json
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'common errors' do
|
17
|
+
describe 'bad request errors' do
|
18
|
+
describe 'no token error' do
|
19
|
+
before do
|
20
|
+
do_request({app_key: 'test_key'})
|
21
|
+
end
|
22
|
+
it 'Raises a bad request (400) error when the parameters don\'t contain the token of the gateway' do
|
23
|
+
expect(last_response.status).to be 400
|
24
|
+
end
|
25
|
+
it 'returns the correct response if the parameters do not contain a gateway token' do
|
26
|
+
expect(JSON.parse(last_response.body)).to eq({'message' => 'bad_request'})
|
27
|
+
end
|
28
|
+
end
|
29
|
+
describe 'no application key error' do
|
30
|
+
before do
|
31
|
+
do_request({token: 'test_token'})
|
32
|
+
end
|
33
|
+
it 'Raises a bad request (400) error when the parameters don\'t contain the application key' do
|
34
|
+
expect(last_response.status).to be 400
|
35
|
+
end
|
36
|
+
it 'returns the correct response if the parameters do not contain a application key' do
|
37
|
+
expect(JSON.parse(last_response.body)).to eq({'message' => 'bad_request'})
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
describe 'not_found errors' do
|
42
|
+
describe 'application not found' do
|
43
|
+
before do
|
44
|
+
do_request({token: 'test_token', app_key: 'another_key'})
|
45
|
+
end
|
46
|
+
it 'Raises a not found (404) error when the key doesn\'t belong to any application' do
|
47
|
+
expect(last_response.status).to be 404
|
48
|
+
end
|
49
|
+
it 'returns the correct body when the gateway doesn\'t exist' do
|
50
|
+
expect(JSON.parse(last_response.body)).to eq({'message' => 'application_not_found'})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
describe 'gateway not found' do
|
54
|
+
before do
|
55
|
+
do_request({token: 'other_token', app_key: 'test_key'})
|
56
|
+
end
|
57
|
+
it 'Raises a not found (404) error when the gateway does\'nt exist' do
|
58
|
+
expect(last_response.status).to be 404
|
59
|
+
end
|
60
|
+
it 'returns the correct body when the gateway doesn\'t exist' do
|
61
|
+
expect(JSON.parse(last_response.body)).to eq({'message' => 'gateway_not_found'})
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
10
66
|
end
|
11
67
|
end
|
12
68
|
end
|