angus 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/angus/base.rb +1 -0
- data/lib/angus/resource_definition.rb +1 -1
- data/lib/angus/version.rb +1 -1
- data/spec/functional/basic/definitions/messages.yml +4 -0
- data/spec/functional/basic/definitions/representations.yml +10 -0
- data/spec/functional/basic/definitions/service.yml +3 -0
- data/spec/functional/basic/definitions/users/operations.yml +37 -0
- data/spec/functional/basic/resources/users.rb +12 -0
- data/spec/functional/basic/services/basic.rb +14 -0
- data/spec/functional/basic_spec.rb +63 -0
- data/spec/functional/empty_resource/definitions/messages.yml +0 -0
- data/spec/functional/empty_resource/definitions/representations.yml +0 -0
- data/spec/functional/empty_resource/definitions/service.yml +3 -0
- data/spec/functional/empty_resource/definitions/users/operations.yml +0 -0
- data/spec/functional/empty_resource/resources/users.rb +3 -0
- data/spec/functional/empty_resource/services/empty_resource.rb +14 -0
- data/spec/functional/empty_resource_spec.rb +67 -0
- data/spec/functional/no_resources/definitions/messages.yml +0 -0
- data/spec/functional/no_resources/definitions/representations.yml +0 -0
- data/spec/functional/no_resources/definitions/service.yml +3 -0
- data/spec/functional/no_resources/services/no_resources.rb +13 -0
- data/spec/functional/no_resources_spec.rb +67 -0
- metadata +68 -2
data/lib/angus/base.rb
CHANGED
data/lib/angus/version.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
get_user:
|
2
|
+
name: Obtener Información de un Usuario
|
3
|
+
description: >
|
4
|
+
Devuelve información del usuario, como por ejemplo e-mail y fecha de nacimiento.
|
5
|
+
|
6
|
+
path: /users/:user_id
|
7
|
+
method: get
|
8
|
+
uri:
|
9
|
+
- element: user_id
|
10
|
+
description: Identificador del usuario
|
11
|
+
|
12
|
+
response:
|
13
|
+
- element: profile
|
14
|
+
description: Perfil del usuario
|
15
|
+
required: true
|
16
|
+
type: user_profile
|
17
|
+
|
18
|
+
messages:
|
19
|
+
- key: ResourceNotFound
|
20
|
+
|
21
|
+
get_users:
|
22
|
+
name: Obtener Lista de usuarios
|
23
|
+
description: >
|
24
|
+
Devuelve lista de usarios.
|
25
|
+
|
26
|
+
path: /users
|
27
|
+
method: get
|
28
|
+
|
29
|
+
response:
|
30
|
+
- element: users
|
31
|
+
description: Perfil del usuario
|
32
|
+
required: true
|
33
|
+
elements_type: user_profile
|
34
|
+
|
35
|
+
messages:
|
36
|
+
- key: ResourceNotFound
|
37
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Users < Angus::BaseResource
|
2
|
+
USERS = [{ :id => 1, :name => 'ac/dc'},{:id => 2, :name => 'madonna' }]
|
3
|
+
|
4
|
+
def get_user
|
5
|
+
{:profile => USERS.find{ |user| user[:id] == params[:user_id].to_i }}
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_users
|
9
|
+
{:users => USERS}
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rack/test'
|
4
|
+
|
5
|
+
require 'functional/basic/services/basic'
|
6
|
+
|
7
|
+
describe Spec::Functional::Basic do
|
8
|
+
include Rack::Test::Methods
|
9
|
+
|
10
|
+
def app
|
11
|
+
Dir.chdir("#{File.dirname(__FILE__ )}/basic")
|
12
|
+
Spec::Functional::Basic.new
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'responds to /' do
|
16
|
+
get '/'
|
17
|
+
|
18
|
+
last_response.status.should eq(200)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'the documentation url' do
|
22
|
+
|
23
|
+
it 'responds to /basic/doc/0.1' do
|
24
|
+
get '/basic/doc/0.1'
|
25
|
+
|
26
|
+
last_response.status.should eq(200)
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when no format' do
|
30
|
+
it 'sets a html content type' do
|
31
|
+
get '/basic/doc/0.1'
|
32
|
+
|
33
|
+
last_response.header['Content-Type'].should eq('text/html')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when json format' do
|
38
|
+
it 'sets a json content type' do
|
39
|
+
get '/basic/doc/0.1?format=json'
|
40
|
+
|
41
|
+
last_response.header['Content-Type'].should eq('application/json')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'an operation url' do
|
48
|
+
|
49
|
+
it 'responds to /basic/api/0.1/users' do
|
50
|
+
get '/basic/api/0.1/users'
|
51
|
+
|
52
|
+
last_response.status.should eq(200)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'sets a json content type' do
|
56
|
+
get '/basic/api/0.1/users'
|
57
|
+
|
58
|
+
last_response.header['Content-Type'].should eq('application/json')
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rack/test'
|
4
|
+
|
5
|
+
require 'functional/empty_resource/services/empty_resource'
|
6
|
+
|
7
|
+
describe Spec::Functional::EmptyResource do
|
8
|
+
include Rack::Test::Methods
|
9
|
+
|
10
|
+
def app
|
11
|
+
Dir.chdir("#{File.dirname(__FILE__ )}/empty_resource")
|
12
|
+
Spec::Functional::EmptyResource.new
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'responds to /' do
|
16
|
+
get '/'
|
17
|
+
|
18
|
+
last_response.status.should eq(200)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'when a unknown url' do
|
22
|
+
|
23
|
+
let(:url) { '/empty_resource/api/0.1/unknown' }
|
24
|
+
|
25
|
+
it 'responds to /basic/doc/0.1' do
|
26
|
+
get url
|
27
|
+
|
28
|
+
last_response.status.should eq(404)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'sets a json content type' do
|
32
|
+
get url
|
33
|
+
|
34
|
+
last_response.header['Content-Type'].should eq('application/json')
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'the documentation url' do
|
40
|
+
|
41
|
+
let(:url) { '/empty_resource/doc/0.1' }
|
42
|
+
|
43
|
+
it 'returns a success status' do
|
44
|
+
get url
|
45
|
+
|
46
|
+
last_response.status.should eq(200)
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when no format' do
|
50
|
+
it 'sets a html content type' do
|
51
|
+
get url
|
52
|
+
|
53
|
+
last_response.header['Content-Type'].should eq('text/html')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when json format' do
|
58
|
+
it 'sets a json content type' do
|
59
|
+
get "#{url}?format=json"
|
60
|
+
|
61
|
+
last_response.header['Content-Type'].should eq('application/json')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rack/test'
|
4
|
+
|
5
|
+
require 'functional/no_resources/services/no_resources'
|
6
|
+
|
7
|
+
describe Spec::Functional::NoResources do
|
8
|
+
include Rack::Test::Methods
|
9
|
+
|
10
|
+
def app
|
11
|
+
Dir.chdir("#{File.dirname(__FILE__ )}/no_resources")
|
12
|
+
Spec::Functional::NoResources.new
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'responds to /' do
|
16
|
+
get '/'
|
17
|
+
|
18
|
+
last_response.status.should eq(200)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'when a unknown url' do
|
22
|
+
|
23
|
+
let(:url) { '/no_resources/api/0.1/unknown' }
|
24
|
+
|
25
|
+
it 'responds to /basic/doc/0.1' do
|
26
|
+
get url
|
27
|
+
|
28
|
+
last_response.status.should eq(404)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'sets a json content type' do
|
32
|
+
get url
|
33
|
+
|
34
|
+
last_response.header['Content-Type'].should eq('application/json')
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'the documentation url' do
|
40
|
+
|
41
|
+
let(:url) { '/no_resources/doc/0.1' }
|
42
|
+
|
43
|
+
it 'returns a success status' do
|
44
|
+
get url
|
45
|
+
|
46
|
+
last_response.status.should eq(200)
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when no format' do
|
50
|
+
it 'sets a html content type' do
|
51
|
+
get url
|
52
|
+
|
53
|
+
last_response.header['Content-Type'].should eq('text/html')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when json format' do
|
58
|
+
it 'sets a json content type' do
|
59
|
+
get "#{url}?format=json"
|
60
|
+
|
61
|
+
last_response.header['Content-Type'].should eq('application/json')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: angus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-11-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: thor
|
@@ -37,6 +37,9 @@ dependencies:
|
|
37
37
|
- - ~>
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0.0'
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.0.3
|
40
43
|
type: :runtime
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -45,6 +48,9 @@ dependencies:
|
|
45
48
|
- - ~>
|
46
49
|
- !ruby/object:Gem::Version
|
47
50
|
version: '0.0'
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.0.3
|
48
54
|
- !ruby/object:Gem::Dependency
|
49
55
|
name: angus-router
|
50
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,6 +59,9 @@ dependencies:
|
|
53
59
|
- - ~>
|
54
60
|
- !ruby/object:Gem::Version
|
55
61
|
version: '0.0'
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 0.0.3
|
56
65
|
type: :runtime
|
57
66
|
prerelease: false
|
58
67
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -61,6 +70,9 @@ dependencies:
|
|
61
70
|
- - ~>
|
62
71
|
- !ruby/object:Gem::Version
|
63
72
|
version: '0.0'
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.0.3
|
64
76
|
- !ruby/object:Gem::Dependency
|
65
77
|
name: rake
|
66
78
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,6 +137,22 @@ dependencies:
|
|
125
137
|
- - ~>
|
126
138
|
- !ruby/object:Gem::Version
|
127
139
|
version: '0.7'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: rack-test
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
144
|
+
requirements:
|
145
|
+
- - ~>
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0.6'
|
148
|
+
type: :development
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
152
|
+
requirements:
|
153
|
+
- - ~>
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0.6'
|
128
156
|
- !ruby/object:Gem::Dependency
|
129
157
|
name: simplecov-rcov
|
130
158
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,6 +245,25 @@ files:
|
|
217
245
|
- lib/angus.rb
|
218
246
|
- spec/spec_helper.rb
|
219
247
|
- spec/angus/rspec/examples/describe_errors_spec.rb
|
248
|
+
- spec/functional/no_resources_spec.rb
|
249
|
+
- spec/functional/empty_resource_spec.rb
|
250
|
+
- spec/functional/basic/resources/users.rb
|
251
|
+
- spec/functional/basic/services/basic.rb
|
252
|
+
- spec/functional/basic/definitions/representations.yml
|
253
|
+
- spec/functional/basic/definitions/users/operations.yml
|
254
|
+
- spec/functional/basic/definitions/messages.yml
|
255
|
+
- spec/functional/basic/definitions/service.yml
|
256
|
+
- spec/functional/empty_resource/resources/users.rb
|
257
|
+
- spec/functional/empty_resource/services/empty_resource.rb
|
258
|
+
- spec/functional/empty_resource/definitions/representations.yml
|
259
|
+
- spec/functional/empty_resource/definitions/users/operations.yml
|
260
|
+
- spec/functional/empty_resource/definitions/messages.yml
|
261
|
+
- spec/functional/empty_resource/definitions/service.yml
|
262
|
+
- spec/functional/basic_spec.rb
|
263
|
+
- spec/functional/no_resources/services/no_resources.rb
|
264
|
+
- spec/functional/no_resources/definitions/representations.yml
|
265
|
+
- spec/functional/no_resources/definitions/messages.yml
|
266
|
+
- spec/functional/no_resources/definitions/service.yml
|
220
267
|
- bin/angus
|
221
268
|
homepage: http://mooveit.github.io/angus-sdoc
|
222
269
|
licenses:
|
@@ -246,3 +293,22 @@ summary: angus
|
|
246
293
|
test_files:
|
247
294
|
- spec/spec_helper.rb
|
248
295
|
- spec/angus/rspec/examples/describe_errors_spec.rb
|
296
|
+
- spec/functional/no_resources_spec.rb
|
297
|
+
- spec/functional/empty_resource_spec.rb
|
298
|
+
- spec/functional/basic/resources/users.rb
|
299
|
+
- spec/functional/basic/services/basic.rb
|
300
|
+
- spec/functional/basic/definitions/representations.yml
|
301
|
+
- spec/functional/basic/definitions/users/operations.yml
|
302
|
+
- spec/functional/basic/definitions/messages.yml
|
303
|
+
- spec/functional/basic/definitions/service.yml
|
304
|
+
- spec/functional/empty_resource/resources/users.rb
|
305
|
+
- spec/functional/empty_resource/services/empty_resource.rb
|
306
|
+
- spec/functional/empty_resource/definitions/representations.yml
|
307
|
+
- spec/functional/empty_resource/definitions/users/operations.yml
|
308
|
+
- spec/functional/empty_resource/definitions/messages.yml
|
309
|
+
- spec/functional/empty_resource/definitions/service.yml
|
310
|
+
- spec/functional/basic_spec.rb
|
311
|
+
- spec/functional/no_resources/services/no_resources.rb
|
312
|
+
- spec/functional/no_resources/definitions/representations.yml
|
313
|
+
- spec/functional/no_resources/definitions/messages.yml
|
314
|
+
- spec/functional/no_resources/definitions/service.yml
|