angus 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +15 -0
  2. data/lib/angus/base.rb +6 -3
  3. data/lib/angus/base_proxy.rb +20 -0
  4. data/lib/angus/base_resource.rb +8 -3
  5. data/lib/angus/generator/templates/definitions/operations.yml.erb +2 -0
  6. data/lib/angus/generator/templates/resources/resource.rb.erb +2 -2
  7. data/lib/angus/generator/thor/resource.rb +1 -1
  8. data/lib/angus/middleware/exception_handler.rb +2 -2
  9. data/lib/angus/request_handler.rb +7 -7
  10. data/lib/angus/rspec/support/examples.rb +3 -2
  11. data/lib/angus/rspec/support/examples/describe_errors.rb +23 -6
  12. data/lib/angus/utils/exceptions/invalid_parameter_type.rb +18 -0
  13. data/lib/angus/utils/exceptions/required_parameter_not_fond.rb +19 -0
  14. data/lib/angus/utils/params_validator.rb +81 -0
  15. data/spec/angus/middleware/exception_handler_spec.rb +16 -1
  16. data/spec/angus/rspec/examples/describe_errors_spec.rb +6 -0
  17. data/spec/functional/basic_spec.rb +2 -2
  18. data/spec/functional/empty_resource_spec.rb +2 -2
  19. data/spec/functional/no_resources_spec.rb +2 -2
  20. data/spec/functional/type_validation/definitions/admins/operations.yml +70 -0
  21. data/spec/functional/type_validation/definitions/messages.yml +0 -0
  22. data/spec/functional/type_validation/definitions/representations.yml +9 -0
  23. data/spec/functional/type_validation/definitions/service.yml +3 -0
  24. data/spec/functional/type_validation/models/admin.rb +1 -0
  25. data/spec/functional/type_validation/resources/admins.rb +35 -0
  26. data/spec/functional/type_validation/services/type_validation.rb +13 -0
  27. data/spec/functional/type_validation_spec.rb +283 -0
  28. data/spec/support/matchers/have_error_response_matcher.rb +40 -0
  29. data/spec/support/matchers/have_in_message_matcher.rb +47 -0
  30. data/spec/support/matchers/have_success_response_matcher.rb +40 -0
  31. metadata +95 -93
@@ -0,0 +1,47 @@
1
+ RSpec::Matchers.define :have_in_message do |expected_message|
2
+
3
+ match do |response|
4
+ begin
5
+ @json = JSON(response.body)
6
+
7
+ is_valid_response?(expected_message)
8
+ rescue JSON::ParserError => exception
9
+ @error = "Error will parsing response: #{exception.message}"
10
+ end
11
+ end
12
+
13
+ description do
14
+ "have in message #{expected_message.inspect}"
15
+ end
16
+
17
+ failure_message_for_should do
18
+ if @error
19
+ @error
20
+ elsif @json && @json['messages']
21
+ "expect #{@json['messages']} to include #{expected_message}"
22
+ else
23
+ "expect #{@json} to include messages in it's keys"
24
+ end
25
+ end
26
+
27
+ failure_message_for_should_not do
28
+ if @error
29
+ @error
30
+ elsif @json && @json['messages']
31
+ "expect #{@json['messages']} not to include #{expected_message}"
32
+ else
33
+ "expect #{@json} to include messages in it's keys"
34
+ end
35
+ end
36
+
37
+ def is_valid_response?(expected_message)
38
+ if @json && @json['messages']
39
+ @actual = @json['messages']
40
+ @expected = expected_message
41
+
42
+ @actual.include?(@expected)
43
+ else
44
+ false
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,40 @@
1
+ RSpec::Matchers.define :have_success_response do
2
+
3
+ match do |response|
4
+ begin
5
+ @json = JSON(response.body)
6
+
7
+ is_valid_response?
8
+ rescue JSON::ParserError => exception
9
+ @error = "Error will parsing response: #{exception.message}"
10
+ end
11
+ end
12
+
13
+ description do
14
+ 'have success response'
15
+ end
16
+
17
+ failure_message_for_should do
18
+ if @error
19
+ @error
20
+ elsif @json && @json['status']
21
+ "expect #{@json['status']} to be success\n#{@json.inspect}"
22
+ else
23
+ "expect #{@json} to include status in it's keys"
24
+ end
25
+ end
26
+
27
+ failure_message_for_should_not do
28
+ if @error
29
+ @error
30
+ elsif @json && @json['status']
31
+ "expect #{@json['status']} to not be success\n#{@json.inspect}"
32
+ else
33
+ "expect #{@json} to include status in it's keys"
34
+ end
35
+ end
36
+
37
+ def is_valid_response?
38
+ @json && @json['status'] == 'success'
39
+ end
40
+ end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
5
- prerelease:
4
+ version: 0.0.10
6
5
  platform: ruby
7
6
  authors:
8
7
  - Pablo Ifran
@@ -16,12 +15,11 @@ authors:
16
15
  autorequire:
17
16
  bindir: bin
18
17
  cert_chain: []
19
- date: 2014-01-03 00:00:00.000000000 Z
18
+ date: 2014-03-21 00:00:00.000000000 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: thor
23
22
  requirement: !ruby/object:Gem::Requirement
24
- none: false
25
23
  requirements:
26
24
  - - ! '>='
27
25
  - !ruby/object:Gem::Version
@@ -29,7 +27,6 @@ dependencies:
29
27
  type: :runtime
30
28
  prerelease: false
31
29
  version_requirements: !ruby/object:Gem::Requirement
32
- none: false
33
30
  requirements:
34
31
  - - ! '>='
35
32
  - !ruby/object:Gem::Version
@@ -37,7 +34,6 @@ dependencies:
37
34
  - !ruby/object:Gem::Dependency
38
35
  name: angus-sdoc
39
36
  requirement: !ruby/object:Gem::Requirement
40
- none: false
41
37
  requirements:
42
38
  - - ~>
43
39
  - !ruby/object:Gem::Version
@@ -48,7 +44,6 @@ dependencies:
48
44
  type: :runtime
49
45
  prerelease: false
50
46
  version_requirements: !ruby/object:Gem::Requirement
51
- none: false
52
47
  requirements:
53
48
  - - ~>
54
49
  - !ruby/object:Gem::Version
@@ -59,7 +54,6 @@ dependencies:
59
54
  - !ruby/object:Gem::Dependency
60
55
  name: angus-router
61
56
  requirement: !ruby/object:Gem::Requirement
62
- none: false
63
57
  requirements:
64
58
  - - ~>
65
59
  - !ruby/object:Gem::Version
@@ -70,7 +64,6 @@ dependencies:
70
64
  type: :runtime
71
65
  prerelease: false
72
66
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
67
  requirements:
75
68
  - - ~>
76
69
  - !ruby/object:Gem::Version
@@ -81,7 +74,6 @@ dependencies:
81
74
  - !ruby/object:Gem::Dependency
82
75
  name: rake
83
76
  requirement: !ruby/object:Gem::Requirement
84
- none: false
85
77
  requirements:
86
78
  - - ! '>='
87
79
  - !ruby/object:Gem::Version
@@ -89,7 +81,6 @@ dependencies:
89
81
  type: :development
90
82
  prerelease: false
91
83
  version_requirements: !ruby/object:Gem::Requirement
92
- none: false
93
84
  requirements:
94
85
  - - ! '>='
95
86
  - !ruby/object:Gem::Version
@@ -97,7 +88,6 @@ dependencies:
97
88
  - !ruby/object:Gem::Dependency
98
89
  name: rspec
99
90
  requirement: !ruby/object:Gem::Requirement
100
- none: false
101
91
  requirements:
102
92
  - - ~>
103
93
  - !ruby/object:Gem::Version
@@ -105,7 +95,6 @@ dependencies:
105
95
  type: :development
106
96
  prerelease: false
107
97
  version_requirements: !ruby/object:Gem::Requirement
108
- none: false
109
98
  requirements:
110
99
  - - ~>
111
100
  - !ruby/object:Gem::Version
@@ -113,7 +102,6 @@ dependencies:
113
102
  - !ruby/object:Gem::Dependency
114
103
  name: faker
115
104
  requirement: !ruby/object:Gem::Requirement
116
- none: false
117
105
  requirements:
118
106
  - - ! '>='
119
107
  - !ruby/object:Gem::Version
@@ -121,7 +109,6 @@ dependencies:
121
109
  type: :development
122
110
  prerelease: false
123
111
  version_requirements: !ruby/object:Gem::Requirement
124
- none: false
125
112
  requirements:
126
113
  - - ! '>='
127
114
  - !ruby/object:Gem::Version
@@ -129,7 +116,6 @@ dependencies:
129
116
  - !ruby/object:Gem::Dependency
130
117
  name: simplecov
131
118
  requirement: !ruby/object:Gem::Requirement
132
- none: false
133
119
  requirements:
134
120
  - - ~>
135
121
  - !ruby/object:Gem::Version
@@ -137,7 +123,6 @@ dependencies:
137
123
  type: :development
138
124
  prerelease: false
139
125
  version_requirements: !ruby/object:Gem::Requirement
140
- none: false
141
126
  requirements:
142
127
  - - ~>
143
128
  - !ruby/object:Gem::Version
@@ -145,7 +130,6 @@ dependencies:
145
130
  - !ruby/object:Gem::Dependency
146
131
  name: rack-test
147
132
  requirement: !ruby/object:Gem::Requirement
148
- none: false
149
133
  requirements:
150
134
  - - ~>
151
135
  - !ruby/object:Gem::Version
@@ -153,7 +137,6 @@ dependencies:
153
137
  type: :development
154
138
  prerelease: false
155
139
  version_requirements: !ruby/object:Gem::Requirement
156
- none: false
157
140
  requirements:
158
141
  - - ~>
159
142
  - !ruby/object:Gem::Version
@@ -161,7 +144,6 @@ dependencies:
161
144
  - !ruby/object:Gem::Dependency
162
145
  name: simplecov-rcov
163
146
  requirement: !ruby/object:Gem::Requirement
164
- none: false
165
147
  requirements:
166
148
  - - ~>
167
149
  - !ruby/object:Gem::Version
@@ -169,7 +151,6 @@ dependencies:
169
151
  type: :development
170
152
  prerelease: false
171
153
  version_requirements: !ruby/object:Gem::Requirement
172
- none: false
173
154
  requirements:
174
155
  - - ~>
175
156
  - !ruby/object:Gem::Version
@@ -177,7 +158,6 @@ dependencies:
177
158
  - !ruby/object:Gem::Dependency
178
159
  name: simplecov-rcov-text
179
160
  requirement: !ruby/object:Gem::Requirement
180
- none: false
181
161
  requirements:
182
162
  - - ~>
183
163
  - !ruby/object:Gem::Version
@@ -185,7 +165,6 @@ dependencies:
185
165
  type: :development
186
166
  prerelease: false
187
167
  version_requirements: !ruby/object:Gem::Requirement
188
- none: false
189
168
  requirements:
190
169
  - - ~>
191
170
  - !ruby/object:Gem::Version
@@ -193,7 +172,6 @@ dependencies:
193
172
  - !ruby/object:Gem::Dependency
194
173
  name: ci_reporter
195
174
  requirement: !ruby/object:Gem::Requirement
196
- none: false
197
175
  requirements:
198
176
  - - ! '>='
199
177
  - !ruby/object:Gem::Version
@@ -201,7 +179,6 @@ dependencies:
201
179
  type: :development
202
180
  prerelease: false
203
181
  version_requirements: !ruby/object:Gem::Requirement
204
- none: false
205
182
  requirements:
206
183
  - - ! '>='
207
184
  - !ruby/object:Gem::Version
@@ -214,129 +191,154 @@ executables:
214
191
  extensions: []
215
192
  extra_rdoc_files: []
216
193
  files:
217
- - lib/angus/responses.rb
218
- - lib/angus/marshallings/marshalling.rb
219
- - lib/angus/marshallings/exceptions.rb
220
- - lib/angus/marshallings/base.rb
221
- - lib/angus/status_codes.rb
222
- - lib/angus/version.rb
194
+ - bin/angus
195
+ - lib/angus.rb
196
+ - lib/angus/base.rb
197
+ - lib/angus/base_actions.rb
198
+ - lib/angus/base_proxy.rb
199
+ - lib/angus/base_resource.rb
223
200
  - lib/angus/commands/angus_command.rb
201
+ - lib/angus/commands/command_processor.rb
202
+ - lib/angus/commands/demo_command.rb
203
+ - lib/angus/commands/help_command.rb
224
204
  - lib/angus/commands/new_service_command.rb
225
- - lib/angus/commands/server_command.rb
226
205
  - lib/angus/commands/resource_command.rb
227
206
  - lib/angus/commands/scaffold_command.rb
228
- - lib/angus/commands/demo_command.rb
229
- - lib/angus/commands/command_processor.rb
230
- - lib/angus/commands/help_command.rb
231
- - lib/angus/base_actions.rb
232
- - lib/angus/request_handler.rb
233
- - lib/angus/renders/html_render.rb
234
- - lib/angus/renders/base.rb
235
- - lib/angus/renders/json_render.rb
207
+ - lib/angus/commands/server_command.rb
208
+ - lib/angus/definition_reader.rb
209
+ - lib/angus/exceptions.rb
236
210
  - lib/angus/generator/templates/Gemfile.erb
237
- - lib/angus/generator/templates/resources/resource.rb.erb
238
211
  - lib/angus/generator/templates/README.md
239
212
  - lib/angus/generator/templates/config.ru.erb
240
- - lib/angus/generator/templates/services/service.rb.erb
241
- - lib/angus/generator/templates/definitions/service.yml.erb
213
+ - lib/angus/generator/templates/definitions/messages.yml.erb
242
214
  - lib/angus/generator/templates/definitions/operations.yml.erb
243
215
  - lib/angus/generator/templates/definitions/representations.yml.erb
244
- - lib/angus/generator/templates/definitions/messages.yml.erb
216
+ - lib/angus/generator/templates/definitions/service.yml.erb
217
+ - lib/angus/generator/templates/resources/resource.rb.erb
218
+ - lib/angus/generator/templates/services/service.rb.erb
219
+ - lib/angus/generator/thor/file_handler.rb
220
+ - lib/angus/generator/thor/helper_methods.rb
245
221
  - lib/angus/generator/thor/new_project.rb
246
222
  - lib/angus/generator/thor/resource.rb
247
- - lib/angus/generator/thor/helper_methods.rb
248
- - lib/angus/generator/thor/file_handler.rb
249
- - lib/angus/base_resource.rb
250
- - lib/angus/response.rb
251
- - lib/angus/exceptions.rb
223
+ - lib/angus/marshallings/base.rb
224
+ - lib/angus/marshallings/exceptions.rb
225
+ - lib/angus/marshallings/marshalling.rb
252
226
  - lib/angus/middleware/exception_handler.rb
227
+ - lib/angus/proxy_actions.rb
228
+ - lib/angus/renders/base.rb
229
+ - lib/angus/renders/html_render.rb
230
+ - lib/angus/renders/json_render.rb
231
+ - lib/angus/request_handler.rb
232
+ - lib/angus/resource_definition.rb
233
+ - lib/angus/response.rb
234
+ - lib/angus/responses.rb
235
+ - lib/angus/rspec/spec_helper.rb
236
+ - lib/angus/rspec/support/examples.rb
253
237
  - lib/angus/rspec/support/examples/describe_errors.rb
254
238
  - lib/angus/rspec/support/matchers/operation_response_matchers.rb
255
239
  - lib/angus/rspec/support/operation_response.rb
256
- - lib/angus/rspec/support/examples.rb
257
- - lib/angus/rspec/spec_helper.rb
258
- - lib/angus/utils/string.rb
259
- - lib/angus/utils/params.rb
260
- - lib/angus/resource_definition.rb
240
+ - lib/angus/status_codes.rb
261
241
  - lib/angus/utils.rb
262
- - lib/angus/definition_reader.rb
263
- - lib/angus/base.rb
264
- - lib/angus/proxy_actions.rb
265
- - lib/angus.rb
266
- - spec/spec_helper.rb
267
- - spec/angus/request_handler_spec.rb
242
+ - lib/angus/utils/exceptions/invalid_parameter_type.rb
243
+ - lib/angus/utils/exceptions/required_parameter_not_fond.rb
244
+ - lib/angus/utils/params.rb
245
+ - lib/angus/utils/params_validator.rb
246
+ - lib/angus/utils/string.rb
247
+ - lib/angus/version.rb
268
248
  - spec/angus/middleware/exception_handler_spec.rb
249
+ - spec/angus/request_handler_spec.rb
269
250
  - spec/angus/rspec/examples/describe_errors_spec.rb
270
- - spec/functional/no_resources_spec.rb
271
- - spec/functional/empty_resource_spec.rb
251
+ - spec/functional/basic/definitions/messages.yml
252
+ - spec/functional/basic/definitions/representations.yml
253
+ - spec/functional/basic/definitions/service.yml
254
+ - spec/functional/basic/definitions/users/operations.yml
272
255
  - spec/functional/basic/exceptions/user_errors.rb
273
256
  - spec/functional/basic/models/user.rb
274
257
  - spec/functional/basic/resources/users.rb
275
258
  - spec/functional/basic/services/basic.rb
276
- - spec/functional/basic/definitions/representations.yml
277
- - spec/functional/basic/definitions/users/operations.yml
278
- - spec/functional/basic/definitions/messages.yml
279
- - spec/functional/basic/definitions/service.yml
280
- - spec/functional/empty_resource/resources/users.rb
281
- - spec/functional/empty_resource/services/empty_resource.rb
282
- - spec/functional/empty_resource/definitions/representations.yml
283
- - spec/functional/empty_resource/definitions/users/operations.yml
259
+ - spec/functional/basic_spec.rb
284
260
  - spec/functional/empty_resource/definitions/messages.yml
261
+ - spec/functional/empty_resource/definitions/representations.yml
285
262
  - spec/functional/empty_resource/definitions/service.yml
286
- - spec/functional/basic_spec.rb
287
- - spec/functional/no_resources/services/no_resources.rb
288
- - spec/functional/no_resources/definitions/representations.yml
263
+ - spec/functional/empty_resource/definitions/users/operations.yml
264
+ - spec/functional/empty_resource/resources/users.rb
265
+ - spec/functional/empty_resource/services/empty_resource.rb
266
+ - spec/functional/empty_resource_spec.rb
289
267
  - spec/functional/no_resources/definitions/messages.yml
268
+ - spec/functional/no_resources/definitions/representations.yml
290
269
  - spec/functional/no_resources/definitions/service.yml
291
- - bin/angus
270
+ - spec/functional/no_resources/services/no_resources.rb
271
+ - spec/functional/no_resources_spec.rb
272
+ - spec/functional/type_validation/definitions/admins/operations.yml
273
+ - spec/functional/type_validation/definitions/messages.yml
274
+ - spec/functional/type_validation/definitions/representations.yml
275
+ - spec/functional/type_validation/definitions/service.yml
276
+ - spec/functional/type_validation/models/admin.rb
277
+ - spec/functional/type_validation/resources/admins.rb
278
+ - spec/functional/type_validation/services/type_validation.rb
279
+ - spec/functional/type_validation_spec.rb
280
+ - spec/spec_helper.rb
281
+ - spec/support/matchers/have_error_response_matcher.rb
282
+ - spec/support/matchers/have_in_message_matcher.rb
283
+ - spec/support/matchers/have_success_response_matcher.rb
292
284
  homepage: http://moove-it.github.io/angus
293
285
  licenses:
294
286
  - MIT
287
+ metadata: {}
295
288
  post_install_message:
296
289
  rdoc_options: []
297
290
  require_paths:
298
291
  - lib
299
292
  required_ruby_version: !ruby/object:Gem::Requirement
300
- none: false
301
293
  requirements:
302
294
  - - ! '>='
303
295
  - !ruby/object:Gem::Version
304
296
  version: '0'
305
297
  required_rubygems_version: !ruby/object:Gem::Requirement
306
- none: false
307
298
  requirements:
308
299
  - - ! '>='
309
300
  - !ruby/object:Gem::Version
310
301
  version: '0'
311
302
  requirements: []
312
303
  rubyforge_project:
313
- rubygems_version: 1.8.25
304
+ rubygems_version: 2.2.2
314
305
  signing_key:
315
- specification_version: 3
306
+ specification_version: 4
316
307
  summary: A web services summary
317
308
  test_files:
318
- - spec/spec_helper.rb
319
- - spec/angus/request_handler_spec.rb
320
309
  - spec/angus/middleware/exception_handler_spec.rb
310
+ - spec/angus/request_handler_spec.rb
321
311
  - spec/angus/rspec/examples/describe_errors_spec.rb
322
- - spec/functional/no_resources_spec.rb
323
- - spec/functional/empty_resource_spec.rb
312
+ - spec/functional/basic/definitions/messages.yml
313
+ - spec/functional/basic/definitions/representations.yml
314
+ - spec/functional/basic/definitions/service.yml
315
+ - spec/functional/basic/definitions/users/operations.yml
324
316
  - spec/functional/basic/exceptions/user_errors.rb
325
317
  - spec/functional/basic/models/user.rb
326
318
  - spec/functional/basic/resources/users.rb
327
319
  - spec/functional/basic/services/basic.rb
328
- - spec/functional/basic/definitions/representations.yml
329
- - spec/functional/basic/definitions/users/operations.yml
330
- - spec/functional/basic/definitions/messages.yml
331
- - spec/functional/basic/definitions/service.yml
332
- - spec/functional/empty_resource/resources/users.rb
333
- - spec/functional/empty_resource/services/empty_resource.rb
334
- - spec/functional/empty_resource/definitions/representations.yml
335
- - spec/functional/empty_resource/definitions/users/operations.yml
320
+ - spec/functional/basic_spec.rb
336
321
  - spec/functional/empty_resource/definitions/messages.yml
322
+ - spec/functional/empty_resource/definitions/representations.yml
337
323
  - spec/functional/empty_resource/definitions/service.yml
338
- - spec/functional/basic_spec.rb
339
- - spec/functional/no_resources/services/no_resources.rb
340
- - spec/functional/no_resources/definitions/representations.yml
324
+ - spec/functional/empty_resource/definitions/users/operations.yml
325
+ - spec/functional/empty_resource/resources/users.rb
326
+ - spec/functional/empty_resource/services/empty_resource.rb
327
+ - spec/functional/empty_resource_spec.rb
341
328
  - spec/functional/no_resources/definitions/messages.yml
329
+ - spec/functional/no_resources/definitions/representations.yml
342
330
  - spec/functional/no_resources/definitions/service.yml
331
+ - spec/functional/no_resources/services/no_resources.rb
332
+ - spec/functional/no_resources_spec.rb
333
+ - spec/functional/type_validation/definitions/admins/operations.yml
334
+ - spec/functional/type_validation/definitions/messages.yml
335
+ - spec/functional/type_validation/definitions/representations.yml
336
+ - spec/functional/type_validation/definitions/service.yml
337
+ - spec/functional/type_validation/models/admin.rb
338
+ - spec/functional/type_validation/resources/admins.rb
339
+ - spec/functional/type_validation/services/type_validation.rb
340
+ - spec/functional/type_validation_spec.rb
341
+ - spec/spec_helper.rb
342
+ - spec/support/matchers/have_error_response_matcher.rb
343
+ - spec/support/matchers/have_in_message_matcher.rb
344
+ - spec/support/matchers/have_success_response_matcher.rb