@@ -294,66 +294,17 @@ def self.parsed?(value)
294
294
end
295
295
end
296
296
297
- it 'Bool' do
298
- subject . params do
299
- requires :bool , coerce : Grape ::API ::Boolean
300
- end
301
- subject . get '/bool' do
302
- params [ :bool ] . class
303
- end
304
-
305
- get '/bool' , bool : 1
306
- expect ( last_response . status ) . to eq ( 200 )
307
- expect ( last_response . body ) . to eq ( 'TrueClass' )
308
-
309
- get '/bool' , bool : 0
310
- expect ( last_response . status ) . to eq ( 200 )
311
- expect ( last_response . body ) . to eq ( 'FalseClass' )
312
-
313
- get '/bool' , bool : 'false'
314
- expect ( last_response . status ) . to eq ( 200 )
315
- expect ( last_response . body ) . to eq ( 'FalseClass' )
316
-
317
- get '/bool' , bool : 'true'
318
- expect ( last_response . status ) . to eq ( 200 )
319
- expect ( last_response . body ) . to eq ( 'TrueClass' )
320
- end
321
-
322
297
it 'Boolean' do
323
298
subject . params do
324
- optional :boolean , type : Boolean , default : true
299
+ requires :boolean , type : Boolean
325
300
end
326
301
subject . get '/boolean' do
327
302
params [ :boolean ] . class
328
303
end
329
304
330
- get '/boolean'
305
+ get '/boolean' , boolean : 1
331
306
expect ( last_response . status ) . to eq ( 200 )
332
307
expect ( last_response . body ) . to eq ( 'TrueClass' )
333
-
334
- get '/boolean' , boolean : true
335
- expect ( last_response . status ) . to eq ( 200 )
336
- expect ( last_response . body ) . to eq ( 'TrueClass' )
337
-
338
- get '/boolean' , boolean : false
339
- expect ( last_response . status ) . to eq ( 200 )
340
- expect ( last_response . body ) . to eq ( 'FalseClass' )
341
-
342
- get '/boolean' , boolean : 'true'
343
- expect ( last_response . status ) . to eq ( 200 )
344
- expect ( last_response . body ) . to eq ( 'TrueClass' )
345
-
346
- get '/boolean' , boolean : 'false'
347
- expect ( last_response . status ) . to eq ( 200 )
348
- expect ( last_response . body ) . to eq ( 'FalseClass' )
349
-
350
- get '/boolean' , boolean : 123
351
- expect ( last_response . status ) . to eq ( 400 )
352
- expect ( last_response . body ) . to eq ( 'boolean is invalid' )
353
-
354
- get '/boolean' , boolean : '123'
355
- expect ( last_response . status ) . to eq ( 400 )
356
- expect ( last_response . body ) . to eq ( 'boolean is invalid' )
357
308
end
358
309
359
310
it 'Rack::Multipart::UploadedFile' do
0 commit comments