@@ -245,7 +245,7 @@ def define_requires_none
245
245
it 'errors when param is not an Array' do
246
246
get '/required' , items : 'hello'
247
247
expect ( last_response . status ) . to eq ( 400 )
248
- expect ( last_response . body ) . to eq ( 'items is invalid, items[key] is missing ' )
248
+ expect ( last_response . body ) . to eq ( 'items is invalid' )
249
249
250
250
get '/required' , items : { key : 'foo' }
251
251
expect ( last_response . status ) . to eq ( 400 )
@@ -337,7 +337,7 @@ def define_requires_none
337
337
338
338
get '/required' , items : [ { key : 'hash in array' } ]
339
339
expect ( last_response . status ) . to eq ( 400 )
340
- expect ( last_response . body ) . to eq ( 'items is invalid, items[0][ key] does not have a valid value' )
340
+ expect ( last_response . body ) . to eq ( 'items is invalid, items[key] does not have a valid value' )
341
341
end
342
342
343
343
it 'works when all params match' do
@@ -507,12 +507,12 @@ def validate_param!(attr_name, params)
507
507
508
508
it 'handle errors for all array elements' do
509
509
get '/within_array' , children : [
510
- { name : 'Jim' , parents : [ { name : 'Joy' } ] } ,
511
- { name : 'Job' , parents : [ { name : nil } , { name : nil } ] }
510
+ { name : 'Jim' , parents : [ ] } ,
511
+ { name : 'Job' , parents : [ ] }
512
512
]
513
513
514
514
expect ( last_response . status ) . to eq ( 400 )
515
- expect ( last_response . body ) . to eq ( 'children[1 ][parents][0][name] is empty , children[1][parents][1][name] is empty ' )
515
+ expect ( last_response . body ) . to eq ( 'children[0 ][parents] is missing , children[1][parents] is missing ' )
516
516
end
517
517
518
518
it 'safely handles empty arrays and blank parameters' do
@@ -527,14 +527,13 @@ def validate_param!(attr_name, params)
527
527
end
528
528
529
529
it 'errors when param is not an Array' do
530
- # NOTE: would be nicer if these just returned 'children is invalid'
531
530
get '/within_array' , children : 'hello'
532
531
expect ( last_response . status ) . to eq ( 400 )
533
- expect ( last_response . body ) . to eq ( 'children is invalid, children[name] is missing, children[parents] is missing, children[parents] is invalid, children[parents][name] is missing ' )
532
+ expect ( last_response . body ) . to eq ( 'children is invalid' )
534
533
535
534
get '/within_array' , children : { name : 'foo' }
536
535
expect ( last_response . status ) . to eq ( 400 )
537
- expect ( last_response . body ) . to eq ( 'children is invalid, children[parents] is missing ' )
536
+ expect ( last_response . body ) . to eq ( 'children is invalid' )
538
537
539
538
get '/within_array' , children : [ name : 'Jay' , parents : { name : 'Fred' } ]
540
539
expect ( last_response . status ) . to eq ( 400 )
@@ -585,7 +584,7 @@ def validate_param!(attr_name, params)
585
584
it 'requires defaults to Array type' do
586
585
get '/req' , planets : 'Jupiter, Saturn'
587
586
expect ( last_response . status ) . to eq ( 400 )
588
- expect ( last_response . body ) . to eq ( 'planets is invalid, planets[name] is missing ' )
587
+ expect ( last_response . body ) . to eq ( 'planets is invalid' )
589
588
590
589
get '/req' , planets : { name : 'Jupiter' }
591
590
expect ( last_response . status ) . to eq ( 400 )
@@ -601,7 +600,7 @@ def validate_param!(attr_name, params)
601
600
it 'optional defaults to Array type' do
602
601
get '/opt' , name : 'Jupiter' , moons : 'Europa, Ganymede'
603
602
expect ( last_response . status ) . to eq ( 400 )
604
- expect ( last_response . body ) . to eq ( 'moons is invalid, moons[name] is missing ' )
603
+ expect ( last_response . body ) . to eq ( 'moons is invalid' )
605
604
606
605
get '/opt' , name : 'Jupiter' , moons : { name : 'Ganymede' }
607
606
expect ( last_response . status ) . to eq ( 400 )
@@ -620,7 +619,7 @@ def validate_param!(attr_name, params)
620
619
it 'group defaults to Array type' do
621
620
get '/grp' , stars : 'Sun'
622
621
expect ( last_response . status ) . to eq ( 400 )
623
- expect ( last_response . body ) . to eq ( 'stars is invalid, stars[name] is missing ' )
622
+ expect ( last_response . body ) . to eq ( 'stars is invalid' )
624
623
625
624
get '/grp' , stars : { name : 'Sun' }
626
625
expect ( last_response . status ) . to eq ( 400 )
@@ -709,7 +708,7 @@ def validate_param!(attr_name, params)
709
708
it "errors when param is present but isn't an Array" do
710
709
get '/optional_group' , items : 'hello'
711
710
expect ( last_response . status ) . to eq ( 400 )
712
- expect ( last_response . body ) . to eq ( 'items is invalid, items[key] is missing ' )
711
+ expect ( last_response . body ) . to eq ( 'items is invalid' )
713
712
714
713
get '/optional_group' , items : { key : 'foo' }
715
714
expect ( last_response . status ) . to eq ( 400 )
0 commit comments