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