Comments (4)
Why do you call Timecop.freeze before the should() call in the above scenario? Isn't the call inside the block passed to should() sufficient? I suspect you want it so that Date.today.to_s(:header) evals properly, but you can do that yourself...you're iterating over the dates you're jumping around to. You don't need Timecop to generate that string.
Please correct me if I'm misinterpreting the issue, but it appears you're only having problems because you're trying to use Timecop to name that test case.
from timecop.
To be clear, I'm suggesting you change:
Timecop.freeze(Date.parse("April #{day}, 2009"))
should "be valid for #{Date.today.to_s(:header)}" do; end
to:
should "be valid for #{Date.parse("April #{day}, 2009").to_s(:header)}" do; end
from timecop.
:-) my bad. I guess, it is more of a "gotcha" to not use Timecop.freeze outside of of test definition. Thanks much.
from timecop.
No worries, glad to have people using the tool :)
from timecop.
Related Issues (20)
- Can we please have a new release HOT 1
- Date.strptime patch causes error HOT 2
- `Date.strptime` breaks for "Feb 2021", "%B %Y" on the 31st of the month HOT 3
- Time is not reset after block when thread_safe is enabled. HOT 1
- Date.parse returns wrong date if only date is specified HOT 1
- 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
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.