Skip to content

Commit

Permalink
Add #on implementation for testing queue
Browse files Browse the repository at this point in the history
  • Loading branch information
wspurgin committed Jul 31, 2023
1 parent dddee3a commit 64f5d4d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/rspec/sidekiq/matchers/have_enqueued_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ def in(interval)
self
end

def on(queue)
@expected_options["queue"] = queue
self
end

def description
"have an enqueued #{klass} job with arguments #{expected_arguments}"
end
Expand Down
14 changes: 14 additions & 0 deletions spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@
expect(worker).to have_enqueued_sidekiq_job(*worker_args_at).at(tomorrow)
end
end

context "#on queue" do
it "matches the queue in the context" do
worker.perform_async(*worker_args)
expect(worker).to have_enqueued_sidekiq_job(*worker_args).on("default")
end

context "when setting queue at runtime" do
it "matches the queue set" do
worker.set(queue: "highest").perform_async(*worker_args)
expect(worker).to have_enqueued_sidekiq_job(*worker_args).on("highest")
end
end
end
end

context 'ActiveJob' do
Expand Down

0 comments on commit 64f5d4d

Please sign in to comment.