The last week I had a spec with a request where I needed to specify the content type and Google sensei didn’t help me.

It took me an hour until I finally found it, so let me show here briefly how to do it just in case I have to find it again.

it 'sets the content type' do
  post 'http://example.com', nil, {'CONTENT_TYPE' => 'application/json'}
  expect(request.content_type).to eq 'application/json'
end

The fact that the content type must be set with an underscore is counterintuitive since the RFC says otherwise.