Comments (5)
I can't say for sure without seeing that code block or a reproduced failing test.
from timecop.
From the test's inspect output, it looks like you're comparing a Time
(from Time.now
) with an ActiveSupport::TimeWithZone
, and your development system's zone is different from the app's configured default. Likely you just need to use Time.zone.now
.
from timecop.
Agreed @ches, the only change in 0.4.5 was to make time instance type consistent for comparisons so if you're having a problem now it's likely because you were comparing instances inconsistently before.
from timecop.
I just discovered that my use of Timecop was incorrect, and that is probably what was causing this problem. I didn't know that I had to do Timecop.return
, for some reason I assumed that it did its own cleanup at the end of an rspec example.
The top example in the Readme is good and clear, so I'm not sure where I got the idea. But I'll submit a tweak to the other example in the readme just in case others run into the same problem.
Thanks for Timecop!!
from timecop.
ack, i take it back, that wasn't what caused my issue. I'm still having the issue, and Time.zone.now
didn't help. it did however make the output more consistent. comparing time Time
objects i get:
foo_at should have been changed to Mon, 08 Oct 2012 16:31:55 UTC +00:00, but is now Mon, 08 Oct 2012 16:31:55 UTC +00:00
(they are identical)
suspecting that the difference is sub-second, I switched the comparison to to_f
of the Time
objects in order to get more meaningful failure output. however the result was that the specs now pass. the same with to_i
.
/cc @ches
from timecop.
Related Issues (20)
- Is call to Timecop.travel(some random time) atomic in nature? HOT 1
- Time#travel should be side-effect free and not resume system clock HOT 10
- .
- Timecop.thread_safe = true by default HOT 1
- Timecop handles GMT/UTC Time objects incorrectly HOT 2
- Doesn't work for `Rails.cache` with `expires_in` HOT 2
- ruby 3.1 support
- Date.strptime returns wrong month for %Y HOT 6
- %W is not handled properly HOT 1
- Ruby 2.5 seems to work? HOT 4
- Using timecop with psych 4.0.5, behavior differs between the test environment and other environments HOT 3
- Timecop.scale to mock existing times HOT 2
- Timecop.freeze not working with expect().to receive HOT 3
- Test
- Need a proper test for making sure we don't change timezones inadvertently
- DateTime parse without date not working properly HOT 5
- DateTime.parse("Wednesday 12:00") format is always returning midnight HOT 1
- Time.now sometimes has greater-than-nanosecond precision when called under Timecop.travel HOT 2
- DateTime.parse does not handle CWeek correctly
- Mocking `Process.clock_gettime` causes `Concurrent::IVar` with timeout to wait indefinitely HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from timecop.