rspec-sidekiq icon indicating copy to clipboard operation
rspec-sidekiq copied to clipboard

have_enqueued_sidekiq_job fails frequently because of nanoseconds

Open lastobelus opened this issue 8 years ago • 1 comments

This generally happens when a time calculation has gone through a db round trip.

My current workaround is to use Timecop to freeze now without nanoseconds at the beginning of each spec:

          now = Timecop.freeze(Time.zone.now.change(nsec: 0))

but I think it would be better if have_enqueued_sidekiq_job dropped nanoseconds from both sides.

lastobelus avatar Feb 15 '17 22:02 lastobelus

:+1:

sobataro avatar Jan 05 '18 08:01 sobataro

I believe this was fixed with https://github.com/wspurgin/rspec-sidekiq/commit/dcc6d037a2333a5af73ead81809b484fd0e9ac13 which drops any fractional second component. However, It's always a good idea to freeze time for any time-based expectations to avoid flaky failures.

wspurgin avatar Jul 27 '23 13:07 wspurgin