end @avatar = mock_model(Avatar)
You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.avatars
How should I spec this?
What is the behaviour you’re trying to specify here? The docstring
says “it should create a user avatar,” but the example code expects
find on the Avatar class and avatar on the User class. And I can’t
tell how the create() code is actually creating anything.
That aside, the nil error is happening because the user() method is
returning nil (in user.avatars). You can fix that by changing this: