Giter Club home page Giter Club logo

Comments (5)

travisjeffery avatar travisjeffery commented on June 24, 2024

I can't say for sure without seeing that code block or a reproduced failing test.

from timecop.

ches avatar ches commented on June 24, 2024

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.

travisjeffery avatar travisjeffery commented on June 24, 2024

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.

jjb avatar jjb commented on June 24, 2024

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.

jjb avatar jjb commented on June 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.