In Rails, how do you functional test a Javascript response format?
Pass in a :format
with your normal params to trigger a response in that format.
get :index, :format => 'js'
No need to mess with your request headers.
with rspec:
it "should render js" do
xhr :get, 'index'
response.content_type.should == Mime::JS
end
and in your controller action:
respond_to do |format|
format.js
end