I am creating a lib
that will use a model
of Rails
, but for the development of this lib
I need to test without the presence of this model
.
Then think of mockar (I'm using the gem rspec-mock ), so I tried:
it '#user_autenticated?' do
allow('User').to receive(:where).and_return([double('User', cpf: '00011122233344')])
auth = Rbot::Auth.new(maestro)
expect(auth.user_autenticated?).not_to be nil
end
But unfortunately I get the error:
"User" does not implement: where
Does anyone know a way out of this problem?