Skip to content

Instantly share code, notes, and snippets.

@andreaseriksson
Created May 18, 2013 13:44
Show Gist options
  • Save andreaseriksson/5604439 to your computer and use it in GitHub Desktop.
Save andreaseriksson/5604439 to your computer and use it in GitHub Desktop.
RSPEC Controller spec #Testing non-HTML controller output
# link_to 'Export', messages_path(format: :csv)
describe 'CSVoutput' do
it "returns a CSV file" do
get :index, format: :csv
expect(response.headers['Content-Type']).to have_content 'text/csv'
end
it 'returns content' do
create(:message,
name: 'Aaron',
email: '[email protected]',
message: 'Testing!')
get :index, format: :csv
response.body.should have_content 'Aaron,[email protected],Testing!'
expect(response.body).to have_content 'Aaron,[email protected],Testing!'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment