Ruby on rails Rspec Rails-模拟当前用户以测试控制器
我已经开始为我的控制器编写测试。对于其中的一次,我需要登录,以检查页面是否呈现等 由于我使用的Desive在用户模型上有一个当前的用户助手,我如何形成我的:Ruby on rails Rspec Rails-模拟当前用户以测试控制器,ruby-on-rails,rspec,Ruby On Rails,Rspec,我已经开始为我的控制器编写测试。对于其中的一次,我需要登录,以检查页面是否呈现等 由于我使用的Desive在用户模型上有一个当前的用户助手,我如何形成我的: 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_
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
这样我就不会出现未定义的“authenticate!”方法(特定于设计)错误了?上有一篇关于这个主题的好文章。基本上,您需要添加designe测试助手,然后在规范需要时调用
sign\u in
以获得有效的当前用户