How to set request headers in rspec request spec?

前端 未结 10 1252
独厮守ぢ
独厮守ぢ 2020-12-04 08:33

In the controller spec, I can set http accept header like this:

request.accept = \"application/json\"

but in the request spec, \"request\"

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 08:47

    To send both xhr: true and headers, I had to do e.g.:

    my_headers = { "HTTP_ACCEPT": "application/json" }
    get my_path, xhr: true, headers: my_headers
    

提交回复
热议问题