We had a similar problem, but using Factory Girl. We solved it like this:
In spec_helper.rb:
config.include Devise::TestHelpers, :type => :controller
In the controller specification (wrapper method only):
def login_user(user) sign_in user end
Then, in each method you require, you can:
login_user(Factory(:user))
... where you defined the user object in the .rb factories. Not sure if this will work with mocks.
Nick boyce
source share