arkaan 0.7.28 → 0.7.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/arkaan/specs.rb +57 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dda739e1f8b590f58b405939abb425845687615a
4
- data.tar.gz: 28e9ff7fba265f8e5f5b6f546ba5577e95b24ed6
3
+ metadata.gz: 09483e1d839504771cff9d137468636842e6cc09
4
+ data.tar.gz: e28e63b7218cc1b597b1049a7d0dbb639f1730be
5
5
  SHA512:
6
- metadata.gz: ce6aa2bf34d246a9402dbe2e335aaa96bb4cb1e8c077ce2d3fcd5df4f09c2561a17642fdfc622f6c5af89e37fb040036b61a6cc80246e31f870f1072c3aa9a05
7
- data.tar.gz: 854725c6deea2fd61562ab0cf2534b12c60cf7e7b1448851c7c156357aba17852b658680cf95b8a74ffe1eff3e9be7fb3b00ade32019993d8dedda9ce887b18d
6
+ metadata.gz: d2639f53963e11609d3d6c314b2a66005c4d7a3479fcb6433476d50c24707811692d78ab0e5f54fac157be90b87390be89a31785dfc774ce12d02f17e4c0da56
7
+ data.tar.gz: 0e61c562d4ada6bcda8113693c815fb429bad067f986e0fe5d0bd22d9313b8c0988e6bd924af9530984e8fe416b1c90a88f26744b53df336024effa70577973f
@@ -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 |verb, parameters|
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arkaan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.28
4
+ version: 0.7.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Courtois