RSS Amplifier

Nick Jones - Product-Focused CTO, Software Engineer and Indie Hacker · Oct 12, 2024

assert_not_enqueued_with

0
Sign in to vote or save

This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.

We only have a assert_no_enqueued_jobs method in ActiveJob::TestHelper, but I often want to ensure that a specific job with specific args hasn’t been queued.

We only have a assert_no_enqueued_jobs method in ActiveJob::TestHelper, but I often want to ensure that a specific job with specific args hasn’t been queued.

1
2
3
4
5
6
7
8
def assert_not_enqueued_with(job: nil, args: nil, &block)
  only = proc do |j|
    (job ? j[:job] == job : true) &&
      (args ? j[:args] == ActiveJob::Arguments.serialize(args) : true)
  end
  assert_no_enqueued_jobs(only:, &block)
end

Read on nickjones.tech

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.