[rspec-users] [cucumber] Cucumber and Chronic

Mark Wilden mark at mwilden.com
Sun Mar 1 14:07:18 EST 2009

On Sun, Mar 1, 2009 at 8:50 AM, Tim Walker <walketim at gmail.com> wrote:
> Now, this works fine, if you’re only testing that you can set the
> clock to "Monday Jan 1, 2009 10:00". It gets more complex quickly when
> you try to do much more than this. Adding chronic to the mix allows us
> to define and use more complex time concepts in plain language. This
> allows for the parsing of sentence fragments such as “next month” and
> “next Tuesday” and combine them in to complex structures such as “next
> Tuesday at 9:00” in a way that our tests continue to run as time
> marches on.
> For example:
>>> sentence = "next tuesday at 3:00 pm"
> => "next tuesday at 3:00 pm"
>>> time = Chronic.parse(sentence)
> => Tue Mar 03 15:00:00 -0700 2009

Just be careful when when basing durations from "now" that daylight
savings time doesn't affect anything.


More information about the rspec-users mailing list