[rspec-devel] [ rspec-Patches-12841 ] Allow stubs to yield consecutive values
noreply at rubyforge.org
noreply at rubyforge.org
Mon Aug 6 02:13:15 EDT 2007
Patches item #12841, was opened at 2007-08-06 00:13
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=3151&aid=12841&group_id=797
Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Pat Maddox (pergesu)
Assigned to: Nobody (None)
Summary: Allow stubs to yield consecutive values
Initial Comment:
Scott Taylor asked,
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?
This patch provides the #and_yield_consecutively method for mocks and stubs.
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=3151&aid=12841&group_id=797
More information about the rspec-devel
mailing list