2024-06-01 rspec have_enqueued_mail / have_enqueued_job / have_performed_job
have_enqueued_mail
Module: RSpec::Rails::Matchers — Documentation for rspec-rails (6.1.2)
expect {
MyMailer.welcome(user).deliver_later
}.to have_enqueued_mail(MyMailer, :welcome)
# Using alias
expect {
MyMailer.welcome(user).deliver_later
}.to enqueue_mail(MyMailer, :welcome)
- alias は
enqueue_mail
が使える
have_enqueued_job
Module: RSpec::Rails::Matchers — Documentation for rspec-rails (6.1.2)
expect {
HeavyLiftingJob.perform_later
}.to have_enqueued_job
# Using alias
expect {
HeavyLiftingJob.perform_later
}.to enqueue_job
expect {
HelloJob.perform_later
HeavyLiftingJob.perform_later
}.to have_enqueued_job(HelloJob).exactly(:once)
- alias は
enqueue_job
が使える
have_performed_job
expect {
perform_enqueued_jobs { HeavyLiftingJob.perform_later }
}.to have_performed_job
expect {
perform_enqueued_jobs {
HelloJob.perform_later
HeavyLiftingJob.perform_later
}
}.to have_performed_job(HelloJob).exactly(:once)