I am wondering what is the best way to mock such expression:
“comment.initiator.group.name”
What I do now is:
comment = mock_model(Comment)
initiator = mock_model(User)
group = mock_model(Group, :name => “Admin”)
initiator.stub!(:group).and_return(group)
comment.stub!(:initiator).and_return(initiator)
So it becomes quite complex when the length of the expression
increases.
Is it possible to do something like this:
controller.stub!(:comment.initiator.group.name).and_return(“Admin”)?
Thank you in advance!