RailsAPI Textmate Bundle →
Textmate bundle for viewing Rails documentation (using railsapi.com).
Content Types in Rails Controllers and RSpec'ing It
From the to_csv plugin README, you can set the content type to text/csv in your rails controller action:
response.headers['Content-Type'] = 'text/csv; charset=iso-8859-1; header=present'
response.headers['Content-Disposition'] = "attachment; filename=users_#{Time.now.strftime("%m-%d-%Y")}.csv"
To RSpec this behavior, this works:
Then "the output should be a CSV" do
response.headers["type"].should have_text('text/csv')
end