You can get all enqueue_jobs from ActiveJob
ActiveJob::Base.queue_adapter.enqueued_jobs
The code above will return all the enqueue jobs, which returns an array of objects
[
{
:job: ExampleJob,
:args: # whatever args,
:queue: name_of_the_queue
},{
:job: AnotherExampleJob,
:args: # whatever args,
:queue: name_of_another_queue
}
]
To filter different jobs (ie. ActionMailer async with deliver_later!), you can
ActionMailer::DeliveryJob.queue_adapter.enqueued_jobs.count{ |x| x[:job] == ActionMailer::DeliveryJob}
# In Rspec, for example,
expect(ActionMailer::DeliveryJob.queue_adapter.enqueued_jobs.count{ |x| x[:job] == ActionMailer::DeliveryJob}).to eq(1) # expecting 1 async email