所有Ruby测试提升:未定义的方法“authenticate”为nil:NilClass [英] All Ruby tests raising: undefined method `authenticate' for nil:NilClass
问题描述
1)管理员: :CommentsController处理GET到索引成功
失败/错误:get:index
undefined方法`authenticate!'为nil:NilClass
#./spec/controllers/admin/comments_controller_spec.rb: 9:在`block(3个级别)< top(必需)>'
124)PostsController处理单个帖子的GET应该呈现显示模板
失败/错误:get:show,:year => '2008',:month => '01',:day => '01',:slug => 'a-post'
undefined方法'authenticate'为nil:NilClass
#./app/controllers/application_controller.rb:18:in`set_current_user_for_model'
#./spec/controllers/ posts_controller_spec.rb:131:在`do_get'
#./spec/controllers/posts_controller_spec.rb:140:in`block(3 levels)in< top(required)>'
项目可以在那里找到=> https://github.com/agilepandas/enki ,以防您想自己运行测试。
这个问题已被@MatthewClosson的Twitter回复
@jeffehh您需要创建一个
spec / support / devise.rb文件作为
在此指定 https://github.com/plataformatec/devise#test-helpers 到
包括设计测试助手#ruby
再次感谢。
Most of my tests are raising the following and I don't understand why. All methods call raise the 'authenticate' error. I've checked the code if there was a method called "authenticate" but there is no such method.
1) Admin::CommentsController handling GET to index is successful
Failure/Error: get :index
undefined method `authenticate!' for nil:NilClass
# ./spec/controllers/admin/comments_controller_spec.rb:9:in `block (3 levels) in <top (required)>'
124) PostsController handling GET for a single post should render show template
Failure/Error: get :show, :year => '2008', :month => '01', :day => '01', :slug => 'a-post'
undefined method `authenticate' for nil:NilClass
# ./app/controllers/application_controller.rb:18:in `set_current_user_for_model'
# ./spec/controllers/posts_controller_spec.rb:131:in `do_get'
# ./spec/controllers/posts_controller_spec.rb:140:in `block (3 levels) in <top (required)>'
The project can be found over there => https://github.com/agilepandas/enki in case you'd like to run the tests your self.
This question has been answered on Twitter by @MatthewClosson
@jeffehh You need to create a spec/support/devise.rb file as specified here https://github.com/plataformatec/devise#test-helpers to include the devise test helpers #ruby
Thanks once again.
这篇关于所有Ruby测试提升:未定义的方法“authenticate”为nil:NilClass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!