How to test for a correct header?

Hi, all!
I'm writing a functional test and I would like to test if my controller gives out right content type for an AJAX Request.

Firstly I do

xhr :post, :my_controller, my_params, {'Accept' => 'text/javascript'}

to simulate the request, but I don't know how to write an assertion. I hoped it would be

assert_equal headers['Content-Type'], 'text/javascript'

but that turned out to give an error.

Could you please give me a hint for correct syntax?

Do a puts and check the value of header[‘Content-Type’]

I did it in controller and was very surprised that request.headers are empty, though I supply them in the test:

xhr :post, :login, my_params, {'Accept' => 'text/javascript'}

But my original point was to check them from within the test. And the test doesn't have a request or response variable, nor header or headers. I wished to know how I can access that information from the test.

If you use the default test that gets generated with your controller,
you should be able to access the response headers via the
@response.headers hash.

Many thanks!

Assigning values to @request hash solved my another problem!

I am so happy!

Yours sincerely,
Damian/Three-eyed Fish