Closed dpoetzsch closed 1 year ago
Expect first
On Aug 17, 2017 11:37 AM, "David Poetzsch-Heffter" notifications@github.com wrote:
I'd expect the following to work (I am already wrapping this in timecop):
Timecop.freeze do Awesomejob.perform_in 0.seconds 'Awesome', true
test with...
expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true).in(0.seconds)end
Am I missing something?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/philostler/rspec-sidekiq/issues/143, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGDd_4nwRdc91Pi5fC1lGL8p8xEluKvks5sZF42gaJpZM4O6cQY .
Actually. I am not sure. I have no idea. Sorry.
On Aug 17, 2017 11:37 AM, "David Poetzsch-Heffter" notifications@github.com wrote:
I'd expect the following to work (I am already wrapping this in timecop):
Timecop.freeze do Awesomejob.perform_in 0.seconds 'Awesome', true
test with...
expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true).in(0.seconds)end
Am I missing something?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/philostler/rspec-sidekiq/issues/143, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGDd_4nwRdc91Pi5fC1lGL8p8xEluKvks5sZF42gaJpZM4O6cQY .
Late to the party but I think the matcher you're looking for is at
e.g.,
Timecop.freeze do
AwesomeJob.perform_in 0.seconds 'Awesome', true
# test with...
expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true).at(Time.now)
end
I'm sure AwesomeJob.perform_in 0.seconds
is contrived for this example... but just calling out that, if one wants something enqueued immediately, one should use perform_async
not peform_in
with a 0 length interval.
I'd expect the following to work (I am already wrapping this in timecop):
Well, it does not work leaving me with no way to check if the job was enqueued for now and not for a later time.
I already checked your code and I think the problem is that you directly return false if the sidekiq job is scheduled at
nil
, but I thinknil
should instead be treated asTime.now
. If you're interested I can open a PR for this.