From 4660eaff38eb098aeb13a103cc8815f2c5efd560 Mon Sep 17 00:00:00 2001 From: Chris Maximin Date: Mon, 11 Sep 2023 22:57:41 +0100 Subject: [PATCH] add spec to EnqueueSidekiqJob --- .../matchers/enqueue_sidekiq_job_spec.rb | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/rspec/sidekiq/matchers/enqueue_sidekiq_job_spec.rb b/spec/rspec/sidekiq/matchers/enqueue_sidekiq_job_spec.rb index c547e40..ab35266 100644 --- a/spec/rspec/sidekiq/matchers/enqueue_sidekiq_job_spec.rb +++ b/spec/rspec/sidekiq/matchers/enqueue_sidekiq_job_spec.rb @@ -177,6 +177,26 @@ end end + context "immediately" do + it "passes if the job is enqueued immediately" do + expect { worker.perform_async }.to enqueue_sidekiq_job.immediately + expect { worker.perform_at(1.hour.ago) }.to enqueue_sidekiq_job.immediately + end + + it "fails if the job is scheduled" do + specific_time = 1.hour.from_now + expect do + expect { worker.perform_at(specific_time) }.to enqueue_sidekiq_job.immediately + end.to raise_error { |error| + lines = error.message.split("\n") + expect(lines).to include( + match(/expected to have an enqueued .* job/), + match(/-{"at"=>nil}/) + ) + } + end + end + describe "chainable" do it "can chain expectations on the job" do specific_time = 1.hour.from_now