[rspec-users] another noob question about stubs

Matt Patterson matt-lists at reprocessed.org
Tue Apr 29 12:22:40 EDT 2008

On 29 Apr 2008, at 17:00, Patrick Aljord wrote:

> I tried to make a stub but with no success, maybe because it's a
> block. Any hint about that one please?

What are you trying to stub?

Are you trying to stub authenticate_with_open_id?

> def open_id_authentication(openid_url)
>   authenticate_with_open_id(openid_url, :required => [:nickname,
> :email], :optional => [:fullname]) do |result, identity_url,
> registration|
>     if result.successful?
>       @user = User.find_or_initialize_by_identity_url(identity_url)
>       ...
>     end
>   end
> end

If so, you could try

).and_yield(:result, :identity_url, :registration)

so that the code in the block actually gets run (a normal stub, or one  
with and_return with simply eat the block). Obviously, make sure that  
it's yielding the values you want it to.



   Matt Patterson | Design & Code
   <matt at reprocessed org> | http://www.reprocessed.org/

More information about the rspec-users mailing list