On Thursday, January 1, 2015 6:37:47 AM UTC-8, Arup Rakshit wrote:
>
>
>> You can stub any arbitrary chain of methods by setting up the stubs 
>> individually:
>>
>> allow(a).to receive(:foo).with(1).and_return(b = double)
>> allow(b).to receive(:bar).with(2).and_return(c = double)
>> allow(c).to receive(:baz).with(3).and_return("it worked")
>>
>> expect(a.foo(1).bar(2).baz(3)).to eq("it worked")
>>
>> HTH,
>> Myron
>>
>
> Myron,
>
> Is this accepted answer is wrong approach to the problem as given ? 
> http://stackoverflow.com/a/8522108/2767755 
>

That answer is fine.  It's equivalent to what I posted above, but using the 
older syntax (`stub`) rather than the newer `allow` syntax, and also using 
blocks for return values rather than `and_return`. 

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/50a9f2f8-5ea4-4b9f-b0a2-715b8ce08844%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to