首页 文章

Rspec - NoMethodError:对象的未定义方法`cookies'

提问于
浏览
0

尝试将rspec测试添加到我的应用程序并出现以下错误:

NoMethodError:未定义的方法`cookies'用于#

这是我的简单代码:

get :my_action, params: { id: @request.id }
expect(response.status).to eq(200)

但我不在我的App项目中使用任何cookie . 为什么'coockies'试图为我的Request模型对象执行?会是什么呢?

PS请求 - 这是我的模型(有: Headers ,:描述)

1 回答

  • 0

    发现错误...我有自己的模型Request,我在RSpec测试中使用实例变量,如:

    @request = Request.create(....
    

    但是RSpec已经使用了这个即时变量:

    request
    => #<ActionController::TestRequest:0x007fa8d3b54fb8
      @controller_class=RequestsController,
      @custom_param_parsers=
    

    该问题与我的数据重写必要的RSpec @request有关

相关问题