Q: How do you stub a method call for a rails unit test such that it returns a…

by admin on June 7, 2008

Q: How do you stub a method call for a rails unit test such that it returns a different value the second time it is called?

A:  stubs(:foo).returns(1,2)
returns 1 the first call, 2 the second, etc.

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>