On Wed, Feb 22, 2012 at 12:54:31PM -0800, gdo wrote:
>
> But now, I need to do automatic test and in the code you use Time.now
> and I can't control the system date to repeat my test.
>
> Is it possible to replace Time.now by
>
> def Rufus.time_now
> if $rufus_time == nil
> return Time.now
> else
> return $rufus_time
> end
> end
>
> with this code I obtain a fine control on time to repeat my tests.
Hello Guillaume,
why not simply override Time.now at the beginning of your tests?
def Time.now
# return your test time...
end
If you want something a bit more sophisticated:
https://github.com/jtrupiano/timecop
There are other such time stopping gems, but I only remember this one.
Best regards,
--
John Mettraux - http://lambda.io/processi