12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- module SendsNotificationEmailsHelper
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- def check_notification
- @checking_notification = true
- reset_notification_checks
- yield
- @checking_notification = false
- end
-
-
-
-
-
-
-
-
-
-
-
-
- def not_sent(args)
- check_in_progress!
- expect(NotificationFactory::Mailer).not_to have_received(:notification).with(
- hash_including(args)
- )
- end
-
-
-
-
-
-
-
-
-
-
-
-
- def sent(args)
- check_in_progress!
- expect(NotificationFactory::Mailer).to have_received(:notification).with(
- hash_including(args)
- ).once
- end
- private
- def reset_notification_checks
- check_in_progress!
- RSpec::Mocks.space.proxy_for(NotificationFactory::Mailer).reset
-
-
- allow(NotificationFactory::Mailer).to receive(:notification).and_call_original
- end
- def check_in_progress!
- return if @checking_notification
- raise "Don't check notification sending without `checking_notification` block around it."
- end
- end
- RSpec.configure do |config|
- config.include SendsNotificationEmailsHelper, sends_notification_emails: true
- end
|