spec/grape/validations_spec.rb in grape-1.3.2 vs spec/grape/validations_spec.rb in grape-1.3.3
- old
+ new
@@ -572,11 +572,11 @@
{ name: 'Job', parents: [{}] }
]
# NOTE: with body parameters in json or XML or similar this
# should actually fail with: children[parents][name] is missing.
expect(last_response.status).to eq(400)
- expect(last_response.body).to eq('children[1][parents] is missing')
+ expect(last_response.body).to eq('children[1][parents] is missing, children[0][parents][1][name] is missing, children[0][parents][1][name] is empty')
end
it 'errors when a parameter is not present in array within array' do
get '/within_array', children: [
{ name: 'Jim', parents: [{ name: 'Joy' }] },
@@ -613,11 +613,11 @@
'children[0][parents][0][name] is empty'
)
get '/within_array', children: [name: 'Jay']
expect(last_response.status).to eq(400)
- expect(last_response.body).to eq('children[0][parents] is missing')
+ expect(last_response.body).to eq('children[0][parents] is missing, children[0][parents][0][name] is missing, children[0][parents][0][name] is empty')
end
it 'errors when param is not an Array' do
get '/within_array', children: 'hello'
expect(last_response.status).to eq(400)
@@ -761,11 +761,11 @@
it 'safely handles empty arrays and blank parameters' do
put_with_json '/within_array', children: []
expect(last_response.status).to eq(200)
put_with_json '/within_array', children: [name: 'Jay']
expect(last_response.status).to eq(400)
- expect(last_response.body).to eq('children[0][parents] is missing')
+ expect(last_response.body).to eq('children[0][parents] is missing, children[0][parents][0][name] is missing')
end
end
context 'optional with an Array block' do
before do
@@ -836,11 +836,11 @@
end
it 'does internal validations if the outer group is present' do
get '/nested_optional_group', items: [{ key: 'foo' }]
expect(last_response.status).to eq(400)
- expect(last_response.body).to eq('items[0][required_subitems] is missing')
+ expect(last_response.body).to eq('items[0][required_subitems] is missing, items[0][required_subitems][0][value] is missing')
get '/nested_optional_group', items: [{ key: 'foo', required_subitems: [{ value: 'bar' }] }]
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('nested optional group works')
end
@@ -856,10 +856,10 @@
end
it 'handles validation within arrays' do
get '/nested_optional_group', items: [{ key: 'foo' }]
expect(last_response.status).to eq(400)
- expect(last_response.body).to eq('items[0][required_subitems] is missing')
+ expect(last_response.body).to eq('items[0][required_subitems] is missing, items[0][required_subitems][0][value] is missing')
get '/nested_optional_group', items: [{ key: 'foo', required_subitems: [{ value: 'bar' }] }]
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('nested optional group works')