Comments (12)
Little update: The issue is that when calling the Zip::DOSTime.now
method (from the inheritance of Time) it return a Time
class object instead of DOSTime
.
from timecop.
This nasty workaround works for me for now:
Given /^the date is "([^"]*)"$/ do |date_string|
Zip::DOSTime.instance_eval do
def now ; Zip::DOSTime.new(Time.now.to_s) ; end
end
Timecop.travel DateTime.parse(date_string + " 00:00:00 -0500")
end
from timecop.
@kpolitowicz Thanks for the patch. I also had the same issue.
from timecop.
@kpolitowicz's do you think there's something that should go in the project, or just throw something in the README about dealing with Zip::DOSTime?
from timecop.
potential fix: yaauie/7c6f531b
Not tested for this particular use-case, but it should allow subclasses of Time, Date, and DateTime to interface with Timecop properly, and works with 1.8.x and 1.9.3.
from timecop.
@yaauie just wrote a script using Rubyzip to try it and it seems good. Thanks! 👍
from timecop.
@travisjeffery @yaauie Thanks, I'll try this out in my project as soon as the updated gem is released.
from timecop.
@kpolitowicz I've already pushed the gem. I messed up the month, but 0.4.5 is the version that has this change.
from timecop.
@travisjeffery I confirm, works like charm without my hack.
from timecop.
I realized I neglected to commit my tests. They are here: yaauie/c87ffc3f8
from timecop.
@kpolitowicz awesome. Thanks again @yaauie
from timecop.
@kpolitowicz +1. Thanks for that, it worked for me as well. I was experiencing the same problem but I was using the delorean gem.
from timecop.
Related Issues (20)
- How to start the console? HOT 4
- 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 3
- DateTime.parse does not handle CWeek correctly
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.