From 2eccd7b53cfd15ed5d4bbdb1ed4abfa6eac8d1b8 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 21 Oct 2025 03:33:30 -0400 Subject: [PATCH] Specs for validation error in API responses (#36507) --- spec/requests/api/v1/accounts/credentials_spec.rb | 5 +++++ spec/requests/api/v1/accounts_spec.rb | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/spec/requests/api/v1/accounts/credentials_spec.rb b/spec/requests/api/v1/accounts/credentials_spec.rb index 84bea97e8..4316c1409 100644 --- a/spec/requests/api/v1/accounts/credentials_spec.rb +++ b/spec/requests/api/v1/accounts/credentials_spec.rb @@ -91,6 +91,11 @@ RSpec.describe 'credentials API' do expect(response).to have_http_status(422) expect(response.content_type) .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 diff --git a/spec/requests/api/v1/accounts_spec.rb b/spec/requests/api/v1/accounts_spec.rb index 0e64915ba..9bbce4877 100644 --- a/spec/requests/api/v1/accounts_spec.rb +++ b/spec/requests/api/v1/accounts_spec.rb @@ -118,6 +118,11 @@ RSpec.describe '/api/v1/accounts' do .to have_http_status(422) expect(response.content_type) .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