This is a problem with the cookies collection in a controller spec in the following environment:
This is how I solved this:
def sign_in(user)
cookies.permanent.signed[:remember_token] = [user.id, user.salt]
current_user = user
@current_user = user
end
def sign_out
current_user = nil
@current_user = nil
cookies.delete(:remember_token)
end
def signed_in?
return !current_user.nil?
end
For some reason you have to set both @current_user and current_user for it to work in Rspec. I'm not sure why but it drove me completely nuts since it was working fine in the browser.