Skip to content

Commit 8737dbd

Browse files
committed
refactor(tests): convert attendance warning email test to delivery assertions
Replaces spy-based mock test with email delivery verification. Changes: - 'sends an attendance warning email' - finds email by recipient and subject - Uses flexible matching to account for other emails in deliveries Removes allow().to receive() and have_received() mocks
1 parent 2d1d4f3 commit 8737dbd

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

spec/models/attendance_warning_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
end
1111

1212
it 'sends an attendance warning email' do
13-
allow(MemberMailer).to receive(:attendance_warning).with(member, member.email).and_call_original
14-
1513
described_class.create(member: member, issued_by: admin)
1614

17-
expect(MemberMailer).to have_received(:attendance_warning).with(member, member.email)
15+
email = ActionMailer::Base.deliveries.find { |e| e.to.include?(member.email) && e.subject.include?('Attendance') }
16+
expect(email).not_to be_nil
1817
end
1918

2019
describe '.scopes' do

0 commit comments

Comments
 (0)