Specs for validation error in API responses (#36507)
This commit is contained in:
@@ -91,6 +91,11 @@ RSpec.describe 'credentials API' do
|
|||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(422)
|
||||||
expect(response.content_type)
|
expect(response.content_type)
|
||||||
.to start_with('application/json')
|
.to start_with('application/json')
|
||||||
|
expect(response.parsed_body)
|
||||||
|
.to include(
|
||||||
|
error: /Validation failed/,
|
||||||
|
details: include(note: contain_exactly(include(error: 'ERR_TOO_LONG', description: /character limit/)))
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,11 @@ RSpec.describe '/api/v1/accounts' do
|
|||||||
.to have_http_status(422)
|
.to have_http_status(422)
|
||||||
expect(response.content_type)
|
expect(response.content_type)
|
||||||
.to start_with('application/json')
|
.to start_with('application/json')
|
||||||
|
expect(response.parsed_body)
|
||||||
|
.to include(
|
||||||
|
error: /Validation failed/,
|
||||||
|
details: include(date_of_birth: contain_exactly(include(error: 'ERR_BELOW_LIMIT', description: /below the age limit/)))
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user