Cucumber steps to travel through time with Timecop
These steps are now part of Spreewald.
Here are some useful examples how to use the attached Cucumbersteps:
When the date is 2011-05-06 When the time is 2011-05-06 17:30
There is also one really awesome step that lets you travel to the past or to the future:
When /^it is (\d+|a|some) (seconds?|minutes?|hours?|days?|months?|years?) (later|earlier)$/
As you can see, you describe the time unit amount in 3 different ways:
- a number, e.g. 5
- the word a
- the word some
Then you can describe the time unit itself. May it be seconds, minutes, ..., or years.
Last but not least you can define the time travel direction. Would you like to have a look at the past, use the word "earlier", otherwise use the word "later" to travel to the future. (Note: Please give me some good stock advice or tell me the lottery numbers when you come back ;-))
For example, you can use the step above like that:
Given it is some years later When I have analyzed the stock market And it is some years earlier Then I should give some stock advice to the author of this note
Note that this will not mock the time in a Selenium-controlled browser window. Use timemachine.js for that.