Testing Json Api

Headers, Headers Headers!! I have tested controller calls numerous times when trying to verify that the json response is coming back correct. However I always forget what to set the headers too. I always know its something to do with the request object, but never remember what to enter to make the format.js cal to fire correctly.

request.env['HTTP_ACCEPT'] = 'application/json, text/javascript, *'

This tells rails that, "hey I am expecting you to return json or javascript".

request.env['CONTENT_TYPE'] = 'application/json'

So my code ended up looking like so: in the spec helper