The follow request spec:
get :index, {
results in 'text/html' being set for the response.content_type. The same get method without the query parameters sets the content type to 'application/json' as it should.
Format needs to be in your query parameters, your currently setting a header.
Use:
get :index, your_params.merge(format: :json)
Most helpful comment
Format needs to be in your query parameters, your currently setting a header.
Use: