In the controller spec, I can set http accept header like this:
request.accept = \"application/json\"
but in the request spec, \"request\"
I have to set up headers separately
request.headers["Accept"] = "application/json"
Trying sending it via get/delete/.... is complete garbage in rails4 and causing pain in my head because it is never send as header but as parameter.
{"Accept" => "application/json"}
I used this in Test::Unit:
@request.env['HTTP_ACCEPT'] = "*/*, application/youtube-client"
get :index
This is working for controller specs, not request specs:
request.headers["My Header"] = "something"
Your question was already answered but in case you want to POST something to another action you have to do this:
post :save, {format: :json, application: {param1: "test", param2: "test"}}