From: Aureliano Calvo Date: 2007-07-08T01:56:31+09:00 Subject: Re: Time Test::Unit Question > James Mead wrote: > > You could try using Mocha (http://mocha.rubyforge.org)... > > > > Time.stubs(:now).returns(the_time_you_want) > > I dig that idea, but I get the current time in the actual DB code. I am > trying to test my DB code just as much as I am testing my Ruby code > here. Why don't you calculate the dates in the tests using Time.now as a base? Like: yesterday = Time.now - /*1 day*/ (not actual ruby code). This should make your tests "time independant" while leaving the data base in its actual state and it only adds a little complexity.