How to set request headers in rspec request spec?

前端 未结 10 1260
独厮守ぢ
独厮守ぢ 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:44

    Using rspec with Rack::Test::Methods

    header 'X_YOUR_HEADER_VAR', 'val'
    get '/path'
    

    The header var will come through as X-Your-Header-Var

提交回复
热议问题