From 4b7f04e3eab274e574289a554f004c4a58e7ef9b Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 16 Feb 2024 02:52:29 -0500 Subject: [PATCH] Reduce `RSpec/MultipleExpectations` in post_status_service spec (#29225) --- spec/services/post_status_service_spec.rb | 28 +++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb index d10a82607e..acbebc5056 100644 --- a/spec/services/post_status_service_spec.rb +++ b/spec/services/post_status_service_spec.rb @@ -32,27 +32,27 @@ RSpec.describe PostStatusService, type: :service do let!(:future) { Time.now.utc + 2.hours } let!(:previous_status) { Fabricate(:status, account: account) } - it 'schedules a status' do - status = subject.call(account, text: 'Hi future!', scheduled_at: future) - expect(status).to be_a ScheduledStatus - expect(status.scheduled_at).to eq future - expect(status.params['text']).to eq 'Hi future!' - end - - it 'does not immediately create a status' do + it 'schedules a status for future creation and does not create one immediately' do media = Fabricate(:media_attachment, account: account) status = subject.call(account, text: 'Hi future!', media_ids: [media.id], scheduled_at: future) - expect(status).to be_a ScheduledStatus - expect(status.scheduled_at).to eq future - expect(status.params['text']).to eq 'Hi future!' - expect(status.params['media_ids']).to eq [media.id] + expect(status) + .to be_a(ScheduledStatus) + .and have_attributes( + scheduled_at: eq(future), + params: include( + 'text' => eq('Hi future!'), + 'media_ids' => contain_exactly(media.id) + ) + ) expect(media.reload.status).to be_nil expect(Status.where(text: 'Hi future!')).to_not exist end - it 'does not change statuses count' do - expect { subject.call(account, text: 'Hi future!', scheduled_at: future, thread: previous_status) }.to_not(change { [account.statuses_count, previous_status.replies_count] }) + it 'does not change statuses_count of account or replies_count of thread previous status' do + expect { subject.call(account, text: 'Hi future!', scheduled_at: future, thread: previous_status) } + .to not_change { account.statuses_count } + .and(not_change { previous_status.replies_count }) end end