There are a chain of methods which gets a user
object. I am trying to mock the following to return a user
in my Factory Girl
@current_user = AuthorizeApiRequest.call(request.headers).result
I can mock the object up until the call
method but I'm stuck at mocking the result
method
allow(AuthorizeApiRequest).to receive(:call).and_return(:user)
I found I need to use receive_message_chain
So this worked for me.
allow(AuthorizeApiRequest).to receive_message_chain(:call, :result).and_return(user)