-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "immediately" matcher #210
Conversation
Thanks @chrismaximin Could you clarify the first statement though?
This statement, on first read, is not true. You can absolutely test that something was enqueued for the future... I'm not against adding an explicit "no wait" option to the matcher - in other words testing, explicitly, that no delay was specified when enqueuing. Could you add specs to |
The statement was too broad indeed. I meant "There is currently no way to check in a whether a job was scheduled or enqueued". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the addition Chris!
@@ -177,6 +177,26 @@ | |||
end | |||
end | |||
|
|||
context "immediately" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😻 Great!
# | ||
# # Without any delay | ||
# expect { AwesomeJob.perform_async }.to enqueue_sidekiq_job.immediately | ||
# expect { AwesomeJob.perform_at(1.hour.ago) }.to enqueue_sidekiq_job.immediately |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙇 Thanks for adding the docs too.
I have a couple things to add for a 4.1 (composable support for example), that this will be included in. Thanks again for the contribution @chrismaximin |
The issue
There is currently no way to check whether a job was scheduled for some point in the future, or enqueued immediately.
Specifically, we can't use
have_enqueued_sidekiq_job.at( ... )
if a job was enqueued immediately.This is because when Sidekiq doesn't add a
"at"
option when the date was in the past, which rspec-sidekiq currently relies on:https://github.com/sidekiq/sidekiq/blob/bd1ca2b94ad73abdfd4347c83be527bb3ff60acb/lib/sidekiq/job.rb#L328C1-L329
This PR
This PR enables this: