I’ve got this example ‘group’:
@mock_user = mock_model(User)
@mock_email_field = mock_model(EmailField, :user => @mock_user)
it “should find existing user by email when asked for
This fails with a message:
should find existing user by email when asked for
Mock ‘EmailField_1001’ received unexpected message :user with (no args)
Note that I defined the @mock_email_field to stub the user method.
If I uncomment the restubbing of the @mock_email_field in the example,
It certainly seems that @mock_email_field points to the same object in
I’ve also tried using stub! in the before block instead or or in
addition to hash stub in mock_model, but unless I stub it in the
example no joy.
A couple of us have been scratching our heads over this and I thought
I’d throw it out to the wider RSpec community.
My blog on Ruby