From: Robert Dober Date: 2006-05-24T23:00:07+09:00 Subject: Re: Overriding Time.now ------=_Part_173906_18418411.1148479204575 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 5/24/06, Robert MannI wrote: > > Hello! > > I have a unit test where I need to simulate a different system time. > > Hence I need Time.now to return a different time than now, say, now + 1 > month > > How can I do this? > > I tried aliasing Time now, but I don't know how to alias class methods. > > class Time > alias_method 'self.original_now', 'self.now' > end > > How can I alias this --or-- is there any better way to simulate a > different > time on calling Time.now? > > > Tips and ideas are greatly appreciated, > Rob Hi class Time class << self alias_method :n, :now end end hope that helps Cheers Robert --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_173906_18418411.1148479204575--