[rspec-devel] [ rspec-Patches-12841 ] Allow stubs to yield consecutive values

Scott Taylor mailing_lists at railsnewbie.com
Mon Aug 6 02:16:27 EDT 2007


Pat Maddox, your my hero.

Scott


On Aug 6, 2007, at 2:13 AM, <noreply at rubyforge.org>   
<noreply at rubyforge.org> wrote:

> 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
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel



More information about the rspec-devel mailing list