0

Try to add rspec tests to my App and have following error:

NoMethodError: undefined method `cookies' for #

Here is my simple code:

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

But I do not use anywhere cookies in my App project. And why 'coockies' try to executes for my Request model object? What could it be?

PS Request - it is my model (has :title, :description)

prosto.vint
  • 1,403
  • 2
  • 17
  • 30
  • Possible duplicate of [Why I'm getting undefined method \`cookies'?](https://stackoverflow.com/questions/29903668/why-im-getting-undefined-method-cookies) – Nick Tomlin Sep 27 '17 at 18:43
  • Possible duplicate of [Rspec error: undefined local variable or method \`cookies' for # – Stuart Sep 27 '17 at 20:56

1 Answers1

0

Found error... I have own model Request, and I use instance variable in RSpec test like:

@request = Request.create(....

But RSpec already uses this instant variable:

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

The issue was related with rewriting necessary RSpec @request with my data

prosto.vint
  • 1,403
  • 2
  • 17
  • 30