[rspec-users] Stubbing Enumerable#each
mailing_lists at railsnewbie.com
Sun Aug 5 22:12:06 EDT 2007
I have a mock of an instance of a class which descends from Array:
class ArrayDescendent < Array; end
#... in the specs...
@descendent = mock ArrayDescendent
How would I stub out ArrayDescendent#each, which is inherited from
Array, to return multiple values successively? I could use
and_yield, but that is raising an arity error (the anonymous function/
block should expect only *one value at a time, but and_yield is
yielding both values once). Should I be using a lambda expression here?
Tips are welcome...Thanks,
More information about the rspec-users