What is the expected behavior when a model has both stub and
should_receive defined for the same method?
I have a helper method which creates an admin "logged in":
def stub_user(is_administrator)
user = stub_model(User)
user.stub(:is_administrator).and_return(is_administrator)
User.stub(:find_by_id).and_return(user)
user
end
def setup_admin
@admin = stub_user(true)
session[:user_id] = @admin.id
end
In an admin controller spec, I have to setup_admin so the specs can get
to the controllers, but then later in particular contexts, I do
@some_user = stub_model(User)
User.should_receive(:find_by_id).and_return(@some_user)
This is to simulate selecting a user from a list and either showing or
editing details. Based on what I'm seeing, it appears that the the
find_by_id return values are getting mixed up. Am I wrong to attempt to
use both of these or should this work as I expect? If the latter, then I
have more digging to do to determine what's going wrong.
Thanks,
Phillip
on 2010-03-02 20:43
on 2010-03-02 20:46
Nevermind. If I would have waited five more minutes before clicking "Send", I would have seen my error. Blech.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.