[rspec-users] getting output of STDOUT in spec
aslak.hellesoy at gmail.com
Tue Apr 10 12:04:36 EDT 2007
This is a variant of the dependency injection principle. It goes hand
in hand with mocking. I recommend martin fowler's DI article for more
On 4/10/07, Ashley Moran <work at ashleymoran.me.uk> wrote:
> 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
> # ...
> Actually I suppose it works for any class. Why didn't I think of
> that before? It's so simple!
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users