-
Notifications
You must be signed in to change notification settings - Fork 225
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
Time.now sometimes has greater-than-nanosecond precision when called under Timecop.travel #420
Comments
I opened #421 as a possible approach to removing this caveat, though I do worry that the test doesn't cover the case when |
Nice, just stumbled over this today. |
Resolved, I added a test explicitly for this. |
Reopening this issue since i had to revert the PR |
What was the issue? |
@jasonkingPNM tests were not passing. I didn't realize the test suite didn't run on this PR when I merged it in it broke tests and I had to revert it because it wasn't obvious what was wrong #430 |
Ah, cool. Thanks. |
Wow, hard to repro:
|
Oh, these are all |
Hello, I have a test that looks like:
Where
EmailPolicy::Actions::Block
callsTime.now
, and serialised the date to interact with other systems, andPreferences::EmailRateLimit
deserialised the date. Times are serialised down to the nanosecond.It failed with:
Which baffled me a bit, since I didn't consider that the
Time
used to calculate6.hours.from_now
would have a fraction of a nanosecond difference to the deserialisedTime
from thePreferences
system.Previously, the test only had the
Timecop.freeze
line & worked great. It was only after adding theTimecop.travel
that the two identical-lookingTime
s started comparing as unequal. So that made me look at how thetravel_offset
was added to create theTime.now
used forTimecop.freeze
, and I saw it was aFloat
with a much higher precision than was possible with a computer clock.I have some ideas on how to change my test to pass, but thought I'd raise this issue to highlight that the
Time
s returned underTimecop.travel
may sometimes have more precision than you might expect, and shouldn't be compared toTime
s created from other sources.The text was updated successfully, but these errors were encountered: