Getting RESTful and wondering how to test your respond_to block in your controller to make sure its returning the right format? Drop these into your test_helper.rb.
def assert_xml assert_match 'application/xml', @response.headers['Content-Type'] end def assert_rss assert_match 'application/rss+xml', @response.headers['Content-Type'] end
Then in your functional tests, use them like this:
def test_return_xml get :index, :format => 'xml' assert_xml end def test_return_rss get :index, :format => 'rss' assert_rss end
Yay!
Popularity: 5% [?]




About
Mmm, Del.icio.us