小编Jef*_* W.的帖子

所有Ruby测试都提出了:nil的未定义方法`authenticate':NilClass

我的大多数测试都提出了以下内容,我不明白为什么.所有方法调用都会引发"authenticate"错误.我检查了代码是否有一个名为"authenticate"的方法,但没有这样的方法.

  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)>'
Run Code Online (Sandbox Code Playgroud)

该项目可以在那里找到=> https://github.com/agilepandas/enki,以防你想自己运行测试.

ruby testing rspec ruby-on-rails devise

131
推荐指数
4
解决办法
4万
查看次数

标签 统计

devise ×1

rspec ×1

ruby ×1

ruby-on-rails ×1

testing ×1