[rspec-users] getting output of STDOUT in spec
Tim Lucas
t.lucas at toolmantim.com
Tue Apr 10 19:25:02 EDT 2007
On 11/04/2007, at 1:23 AM, Ashley Moran wrote:
> Aha - this gives me an idea about the dreaded "current-time" problem
>
> def do_something(time_factory=Time)
> time = time_factory.new
> # ...
> end
>
> Actually I suppose it works for any class. Why didn't I think of
> that before? It's so simple!
Usually I just have "today" or "now" as a parameter:
def do_something(now=Time.now)
# ...
end
def do_something(today=Date.today)
# ...
end
Though there's no reason you couldn't mock those two method calls...
-- tim
More information about the rspec-users
mailing list