It's difficult to give you an answer without more details of the test
and the code under test, but I will have a guess. If these suggestions
don't work, then please send us more complete code for the test and
the code under test.
You need to be clear what instance of the model you are setting up the
stub on. It looks like the code under test is doing a database lookup
of the model you have created in create_new_model. Assuming you are
using ActiveRecord or something similar, the code under test will
obtain a different *instance* of the model which will not have the
stub set up on it. You seem to have realised this in the case of the
stub for the do_something method, because you are using any_instance,
but for the errors method you are not. There are a few ways of solving
this, here are a couple of ideas :-
1) Use any_instance for the errors stub :-
model = create_new_model
Model.any_instance.stubs(:do_something).returns(false)
Model.any_instance.stubs(:errors).returns({'base'=>'password'})
method.new(model.id).perform
2) Stub the database lookup and return the instance you have created
in the test (note that in this case you may no longer need to save the
instance to the database in create_new_model) :-
model = build_new_model
model.stubs(:do_something).returns(false)
model.stubs(:errors).returns({'base'=>'password'})
Model.stubs(:find).with(model.id).returns(model)
method.new(model.id).perform
Cheers, James.