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

php - How to display all orders for a single product showing the most recent first? Woocommerce -

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

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -