Hi,
I actually implemented the test to test DelayedJob processing sending emails. The test is actually pretty simple.
You should enqueue 2 jobs (instead of 100), one with high priority, and one with lower priority. You then can use the "Delayed::Job.work_off" method to execute the first job, then assert that the lower priority job is still in the db waiting. If you are still unsure about how to execute a job, take a look at the library. The code is pretty well written.
Here's the code excerpt from my application. Basically I need to send out reminder emails to users, so I need to make sure that the jobs are executed properly and the mailer doesn't bomb out. I put this test in the reminder_test.rb unit test file since the Reminder model knows all about how to enqueue and send out emails.
# enqueue the jobs here
assert_difference 'Delayed::Job.count', -1, 'Job should execute successfully' do
assert_difference 'ActionMailer::Base.deliveries.count' do
Delayed::Job.work_off
end
end
# make sure the email was properly delivered
email = ActionMailer::Base.deliveries.last
assert_equal email.to[0], @user.email
assert (Time.now - @reminder.reload.sent_at) < 1.seconds
Cheers! Hope this help
Alex