0
由於ApplicationController方法logged_in?
想要返回用戶,因此查看規範失敗。RSpec:在視圖中存根控制器方法
不知道如何規範這一點。目前在before(:each)
我:
controller.stub!(:logged_in?).and_return(FactoryGirl.create(:active_user))
@ballots = FactoryGirl.create_list(:full_ballot, 2)
這是不工作:
Failure/Error: render
ActionView::Template::Error:
undefined method 'logged_in?' for #<#<Class:0x007f9c908e4b10>:0x007f9c90873b68>
FWIW::active_user
是針對連接到:full_ballot
更新用戶的用戶工廠:根據要求:
class ApplicationController < ActionController::Base
...
def current_user
@current_user ||= User.find(cookies[:id_token]) if cookies[:id_token]
end
def logged_in?
current_user
end
...
end
你可以發佈你的'current_user'和'logged_in?'方法嗎? – James 2012-02-25 20:47:34