ruby on rails - Mocking chain of methods in rspec -


there chain of methods gets user object. trying mock following return user in factory girl

@current_user = authorizeapirequest.call(request.headers).result 

i can mock object until call method i'm stuck @ mocking result method

allow(authorizeapirequest).to receive(:call).and_return(:user) 

i found need use receive_message_chain

so worked me.

allow(authorizeapirequest).to receive_message_chain(:call, :result).and_return(user) 

Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -