[rspec-users] getting output of STDOUT in spec
Ashley Moran
work at ashleymoran.me.uk
Tue Apr 10 11:23:36 EDT 2007
On 10 Apr 2007, at 13:21, aslak hellesoy wrote:
> def name_to_terminal(io=STDOUT)
> io.puts "Scott Taylor"
> end
>
> then call it from a spec passing in a mock for io with the appropriate
> expectation
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!
More information about the rspec-users
mailing list