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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9eb2ae4d9f7b82ca6e9bafdf86dfb811cdadab3f964b62dbcfa1f47eb9af952
4
- data.tar.gz: 494f4a9ba4dcbe8f5f2d92f08edd3d48df23c7228f1191fa0db1d01caeb6f511
3
+ metadata.gz: 0cd86829736be01f12a1db35c85f32513ad867d7d1da90653e5ea72daaab4b6c
4
+ data.tar.gz: 91c4df3d59ad15bbd01863dda00b579dbfe036c784c1032811e38ad2be74afe0
5
5
  SHA512:
6
- metadata.gz: 2cd7755448f747c7a5e4f3b15dd094b59c71e991aab96d537940cdbd75e39e0f099f75ff35297c0053b67e70d2a16dcde7487642a5ae8775bd53310246412c6d
7
- data.tar.gz: '00875e5e4f232859121c7114b3fb17fbdfc38eda4bcd37ab3c4c9fee308608d3734f0ff9c1fb1d89eecc68d2696233e7018614874efdb13773e2a34c86f96017'
6
+ metadata.gz: a898038115a0536877da85e88106e41ddba528980ef1e5cd3ae19c2a6781ecf2e3ab91b63ef63de9a061cdcaf6409ad8a0fe7d2a3d791ef0e0244480cb316535
7
+ data.tar.gz: db2d41f21c9da67b47394643485df87f90c8b0d8b9727ab0d3a8098ca84e4fc811cd47d2db264b2bb58b56413360609d97035818a2c867bda9728581e75afcee
@@ -13,7 +13,8 @@ module Virtuatable
13
13
  end
14
14
 
15
15
  def load_environment!
16
- Dotenv.load("#{mode}.env")
16
+ Dotenv.load('.env', "#{mode}.env")
17
+ Virtuatable::Specs.include_shared_examples
17
18
  end
18
19
  end
19
20
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Virtuatable
4
- VERSION = '0.3.2'
4
+ VERSION = '0.4.0'
5
5
  end
data/lib/virtuatable.rb CHANGED
@@ -9,4 +9,5 @@ module Virtuatable
9
9
  autoload :Controllers, 'virtuatable/controllers'
10
10
  autoload :Helpers, 'virtuatable/helpers'
11
11
  autoload :Loader, 'virtuatable/application'
12
+ autoload :Specs, 'virtuatable/specs'
12
13
  end
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.3.2
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: