Rspec Rails - 模拟成为current_user来测试控制器
问题描述:
我已经开始为我的控制器编写测试。对于其中一次,我需要登录,以检查页面是否呈现等。Rspec Rails - 模拟成为current_user来测试控制器
因为我使用的Devise在用户模型上有一个current_user helper,我该如何形成我的:
describe "when it GETS 'town'" do
it "should render the template and be successful" do
get :index
response.should render_template(:index)
response.should be_success
end
end
这样我就不会得到未定义的“验证!”方法(设计特定)错误?