Assert about user/account changes

This commit is contained in:
Matt Jankowski 2025-09-04 17:21:15 -04:00
parent c7353765ac
commit 4149728d38

View File

@ -110,9 +110,12 @@ RSpec.describe '/api/v1/accounts' do
let(:date_of_birth) { 13.years.ago.strftime('%d.%m.%Y') } let(:date_of_birth) { 13.years.ago.strftime('%d.%m.%Y') }
it 'returns http unprocessable entity' do it 'returns http unprocessable entity' do
subject expect { subject }
.to not_change(User, :count)
.and not_change(Account, :count)
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')
end end
@ -122,9 +125,12 @@ RSpec.describe '/api/v1/accounts' do
let(:date_of_birth) { 17.years.ago.strftime('%d.%m.%Y') } let(:date_of_birth) { 17.years.ago.strftime('%d.%m.%Y') }
it 'creates a user', :aggregate_failures do it 'creates a user', :aggregate_failures do
subject expect { subject }
.to change(User, :count).by(1)
.and change(Account, :count).by(1)
expect(response).to have_http_status(200) expect(response)
.to have_http_status(200)
expect(response.content_type) expect(response.content_type)
.to start_with('application/json') .to start_with('application/json')
end end
@ -134,7 +140,9 @@ RSpec.describe '/api/v1/accounts' do
let(:date_of_birth) { 17.years.ago.to_date.iso8601 } let(:date_of_birth) { 17.years.ago.to_date.iso8601 }
it 'creates a user', :aggregate_failures do it 'creates a user', :aggregate_failures do
subject expect { subject }
.to change(User, :count).by(1)
.and change(Account, :count).by(1)
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)