I am trying to write specs for a controller without using fixtures (instead employing mock models). This controller requires a user to be logged in, for which I'm employing AuthLogic, following the author's recommendations.
describe UsersController do
def mock_user(stubs={})
@mock_user ||= mock_model(User, stubs)
end
context 'when logged in' do
before { activate_authlogic }
it "exposes the logged-in user as @user in response to GET (show)" do
UserSession.create(mock_user)
...
end
...
end
...
end
These examples all fail at the line UserSession.create(...)
, reporting to the effect of:
Mock 'User_1005' received unexpected message :changed? with (no args)
I'm not sure how to resolve this; is mocking with :changed? => false
appropriate?