grape 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grape might be problematic. Click here for more details.

Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -1
  4. data/CHANGELOG.md +18 -0
  5. data/Gemfile +1 -1
  6. data/README.md +124 -9
  7. data/UPGRADING.md +66 -0
  8. data/gemfiles/rails_3.gemfile +1 -1
  9. data/gemfiles/rails_4.gemfile +1 -1
  10. data/lib/grape.rb +4 -0
  11. data/lib/grape/api.rb +1 -5
  12. data/lib/grape/dsl/inside_route.rb +2 -1
  13. data/lib/grape/dsl/parameters.rb +20 -9
  14. data/lib/grape/dsl/routing.rb +11 -1
  15. data/lib/grape/error_formatter/base.rb +1 -1
  16. data/lib/grape/exceptions/invalid_accept_header.rb +10 -0
  17. data/lib/grape/exceptions/invalid_message_body.rb +10 -0
  18. data/lib/grape/exceptions/missing_group_type.rb +10 -0
  19. data/lib/grape/exceptions/unsupported_group_type.rb +10 -0
  20. data/lib/grape/http/request.rb +1 -0
  21. data/lib/grape/locale/en.yml +11 -0
  22. data/lib/grape/middleware/base.rb +1 -1
  23. data/lib/grape/middleware/formatter.rb +2 -0
  24. data/lib/grape/middleware/versioner/header.rb +14 -11
  25. data/lib/grape/parser/json.rb +3 -0
  26. data/lib/grape/parser/xml.rb +3 -0
  27. data/lib/grape/validations/params_scope.rb +20 -4
  28. data/lib/grape/validations/validators/coerce.rb +4 -1
  29. data/lib/grape/validations/validators/values.rb +1 -1
  30. data/lib/grape/version.rb +1 -1
  31. data/spec/grape/api_spec.rb +3 -3
  32. data/spec/grape/dsl/parameters_spec.rb +11 -11
  33. data/spec/grape/dsl/routing_spec.rb +13 -4
  34. data/spec/grape/endpoint_spec.rb +2 -2
  35. data/spec/grape/exceptions/body_parse_errors_spec.rb +105 -0
  36. data/spec/grape/exceptions/invalid_accept_header_spec.rb +330 -0
  37. data/spec/grape/integration/rack_spec.rb +32 -0
  38. data/spec/grape/middleware/base_spec.rb +20 -0
  39. data/spec/grape/middleware/versioner/header_spec.rb +74 -96
  40. data/spec/grape/validations/params_scope_spec.rb +124 -0
  41. data/spec/grape/validations/validators/allow_blank_spec.rb +102 -0
  42. data/spec/grape/validations/validators/values_spec.rb +45 -1
  43. data/spec/grape/validations_spec.rb +54 -16
  44. data/spec/shared/versioning_examples.rb +32 -0
  45. metadata +61 -51
@@ -107,6 +107,38 @@ shared_examples_for 'versioning' do
107
107
  end
108
108
  end
109
109
 
110
+ context 'with before block defined within a version block' do
111
+ it 'calls before block that is defined within the version block' do
112
+ subject.format :txt
113
+ subject.prefix 'api'
114
+ subject.version 'v2', macro_options do
115
+ before do
116
+ @output ||= 'v2-'
117
+ end
118
+ get 'version' do
119
+ @output += 'version'
120
+ end
121
+ end
122
+
123
+ subject.version 'v1', macro_options do
124
+ before do
125
+ @output ||= 'v1-'
126
+ end
127
+ get 'version' do
128
+ @output += 'version'
129
+ end
130
+ end
131
+
132
+ versioned_get '/version', 'v1', macro_options.merge(prefix: subject.prefix)
133
+ expect(last_response.status).to eq(200)
134
+ expect(last_response.body).to eq('v1-version')
135
+
136
+ versioned_get '/version', 'v2', macro_options.merge(prefix: subject.prefix)
137
+ expect(last_response.status).to eq(200)
138
+ expect(last_response.body).to eq('v2-version')
139
+ end
140
+ end
141
+
110
142
  it 'does not overwrite version parameter with API version' do
111
143
  subject.format :txt
112
144
  subject.version 'v1', macro_options
metadata CHANGED
@@ -1,293 +1,293 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-28 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack-mount
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rack-accept
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: multi_json
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.3.2
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.3.2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: multi_xml
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.5.2
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.5.2
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: hashie
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: 2.1.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: 2.1.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: virtus
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: 1.0.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: 1.0.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: builder
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - '>='
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: grape-entity
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - '>='
144
144
  - !ruby/object:Gem::Version
145
145
  version: 0.4.4
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ">="
150
+ - - '>='
151
151
  - !ruby/object:Gem::Version
152
152
  version: 0.4.4
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rake
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ">="
157
+ - - '>='
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ">="
164
+ - - '>='
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: maruku
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ">="
171
+ - - '>='
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ">="
178
+ - - '>='
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: yard
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ">="
185
+ - - '>='
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ">="
192
+ - - '>='
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: rack-test
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - ">="
199
+ - - '>='
200
200
  - !ruby/object:Gem::Version
201
201
  version: '0'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - ">="
206
+ - - '>='
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: rspec
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
- - - "~>"
213
+ - - ~>
214
214
  - !ruby/object:Gem::Version
215
215
  version: '3.0'
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
- - - "~>"
220
+ - - ~>
221
221
  - !ruby/object:Gem::Version
222
222
  version: '3.0'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: bundler
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
- - - ">="
227
+ - - '>='
228
228
  - !ruby/object:Gem::Version
229
229
  version: '0'
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
- - - ">="
234
+ - - '>='
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0'
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: cookiejar
239
239
  requirement: !ruby/object:Gem::Requirement
240
240
  requirements:
241
- - - ">="
241
+ - - '>='
242
242
  - !ruby/object:Gem::Version
243
243
  version: '0'
244
244
  type: :development
245
245
  prerelease: false
246
246
  version_requirements: !ruby/object:Gem::Requirement
247
247
  requirements:
248
- - - ">="
248
+ - - '>='
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0'
251
251
  - !ruby/object:Gem::Dependency
252
252
  name: rack-contrib
253
253
  requirement: !ruby/object:Gem::Requirement
254
254
  requirements:
255
- - - ">="
255
+ - - '>='
256
256
  - !ruby/object:Gem::Version
257
257
  version: '0'
258
258
  type: :development
259
259
  prerelease: false
260
260
  version_requirements: !ruby/object:Gem::Requirement
261
261
  requirements:
262
- - - ">="
262
+ - - '>='
263
263
  - !ruby/object:Gem::Version
264
264
  version: '0'
265
265
  - !ruby/object:Gem::Dependency
266
266
  name: mime-types
267
267
  requirement: !ruby/object:Gem::Requirement
268
268
  requirements:
269
- - - ">="
269
+ - - '>='
270
270
  - !ruby/object:Gem::Version
271
271
  version: '0'
272
272
  type: :development
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
- - - ">="
276
+ - - '>='
277
277
  - !ruby/object:Gem::Version
278
278
  version: '0'
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: appraisal
281
281
  requirement: !ruby/object:Gem::Requirement
282
282
  requirements:
283
- - - ">="
283
+ - - '>='
284
284
  - !ruby/object:Gem::Version
285
285
  version: '0'
286
286
  type: :development
287
287
  prerelease: false
288
288
  version_requirements: !ruby/object:Gem::Requirement
289
289
  requirements:
290
- - - ">="
290
+ - - '>='
291
291
  - !ruby/object:Gem::Version
292
292
  version: '0'
293
293
  description: A Ruby framework for rapid API development with great conventions.
@@ -297,12 +297,12 @@ executables: []
297
297
  extensions: []
298
298
  extra_rdoc_files: []
299
299
  files:
300
- - ".gitignore"
301
- - ".rspec"
302
- - ".rubocop.yml"
303
- - ".rubocop_todo.yml"
304
- - ".travis.yml"
305
- - ".yardopts"
300
+ - .gitignore
301
+ - .rspec
302
+ - .rubocop.yml
303
+ - .rubocop_todo.yml
304
+ - .travis.yml
305
+ - .yardopts
306
306
  - Appraisals
307
307
  - CHANGELOG.md
308
308
  - CONTRIBUTING.md
@@ -341,14 +341,18 @@ files:
341
341
  - lib/grape/error_formatter/xml.rb
342
342
  - lib/grape/exceptions/base.rb
343
343
  - lib/grape/exceptions/incompatible_option_values.rb
344
+ - lib/grape/exceptions/invalid_accept_header.rb
344
345
  - lib/grape/exceptions/invalid_formatter.rb
346
+ - lib/grape/exceptions/invalid_message_body.rb
345
347
  - lib/grape/exceptions/invalid_versioner_option.rb
346
348
  - lib/grape/exceptions/invalid_with_option_for_represent.rb
349
+ - lib/grape/exceptions/missing_group_type.rb
347
350
  - lib/grape/exceptions/missing_mime_type.rb
348
351
  - lib/grape/exceptions/missing_option.rb
349
352
  - lib/grape/exceptions/missing_vendor_option.rb
350
353
  - lib/grape/exceptions/unknown_options.rb
351
354
  - lib/grape/exceptions/unknown_validator.rb
355
+ - lib/grape/exceptions/unsupported_group_type.rb
352
356
  - lib/grape/exceptions/validation.rb
353
357
  - lib/grape/exceptions/validation_errors.rb
354
358
  - lib/grape/formatter/base.rb
@@ -414,6 +418,8 @@ files:
414
418
  - spec/grape/dsl/validations_spec.rb
415
419
  - spec/grape/endpoint_spec.rb
416
420
  - spec/grape/entity_spec.rb
421
+ - spec/grape/exceptions/body_parse_errors_spec.rb
422
+ - spec/grape/exceptions/invalid_accept_header_spec.rb
417
423
  - spec/grape/exceptions/invalid_formatter_spec.rb
418
424
  - spec/grape/exceptions/invalid_versioner_option_spec.rb
419
425
  - spec/grape/exceptions/missing_mime_type_spec.rb
@@ -421,6 +427,7 @@ files:
421
427
  - spec/grape/exceptions/unknown_options_spec.rb
422
428
  - spec/grape/exceptions/unknown_validator_spec.rb
423
429
  - spec/grape/exceptions/validation_errors_spec.rb
430
+ - spec/grape/integration/rack_spec.rb
424
431
  - spec/grape/loading_spec.rb
425
432
  - spec/grape/middleware/auth/base_spec.rb
426
433
  - spec/grape/middleware/auth/dsl_spec.rb
@@ -469,17 +476,17 @@ require_paths:
469
476
  - lib
470
477
  required_ruby_version: !ruby/object:Gem::Requirement
471
478
  requirements:
472
- - - ">="
479
+ - - '>='
473
480
  - !ruby/object:Gem::Version
474
481
  version: '0'
475
482
  required_rubygems_version: !ruby/object:Gem::Requirement
476
483
  requirements:
477
- - - ">="
484
+ - - '>='
478
485
  - !ruby/object:Gem::Version
479
486
  version: '0'
480
487
  requirements: []
481
488
  rubyforge_project: grape
482
- rubygems_version: 2.2.2
489
+ rubygems_version: 2.4.5
483
490
  signing_key:
484
491
  specification_version: 4
485
492
  summary: A simple Ruby framework for building REST-like APIs.
@@ -499,6 +506,8 @@ test_files:
499
506
  - spec/grape/dsl/validations_spec.rb
500
507
  - spec/grape/endpoint_spec.rb
501
508
  - spec/grape/entity_spec.rb
509
+ - spec/grape/exceptions/body_parse_errors_spec.rb
510
+ - spec/grape/exceptions/invalid_accept_header_spec.rb
502
511
  - spec/grape/exceptions/invalid_formatter_spec.rb
503
512
  - spec/grape/exceptions/invalid_versioner_option_spec.rb
504
513
  - spec/grape/exceptions/missing_mime_type_spec.rb
@@ -506,6 +515,7 @@ test_files:
506
515
  - spec/grape/exceptions/unknown_options_spec.rb
507
516
  - spec/grape/exceptions/unknown_validator_spec.rb
508
517
  - spec/grape/exceptions/validation_errors_spec.rb
518
+ - spec/grape/integration/rack_spec.rb
509
519
  - spec/grape/loading_spec.rb
510
520
  - spec/grape/middleware/auth/base_spec.rb
511
521
  - spec/grape/middleware/auth/dsl_spec.rb