Stub and should_receive

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)

def setup_admin
@admin = stub_user(true)
session[:user_id] =

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)

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.


Nevermind. If I would have waited five more minutes before clicking
“Send”, I would have seen my error.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs