From a255dac787e9f2c715be79f909cfe8f10ac239f6 Mon Sep 17 00:00:00 2001 From: CJ Bryan Date: Mon, 18 Jan 2016 14:54:38 -0500 Subject: [PATCH] Integration tests that wrap CSV exporting. - Pays for my sins. - Related to: https://github.com/codeforamerica/cityvoice/commit/6a822134e9e3df00dee4e0c19906408d65632405#commitcomment-15480922 --- spec/features/export_spec.rb | 40 ++++++++++++++++++++++++++ spec/support/fixtures/valid_export.csv | 2 ++ 2 files changed, 42 insertions(+) create mode 100644 spec/features/export_spec.rb create mode 100644 spec/support/fixtures/valid_export.csv diff --git a/spec/features/export_spec.rb b/spec/features/export_spec.rb new file mode 100644 index 0000000..85a71dd --- /dev/null +++ b/spec/features/export_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe 'Exporting' do + let(:export_data_path) { Rails.root.join('spec', 'support', 'fixtures', 'valid_export.csv') } + let(:export_data) { File.read(export_data_path) } + + let(:location) { FactoryGirl.create(:location, name: 'El Farolito') } + let(:call) { FactoryGirl.create(:call, id: 456, location: location) } + + let!(:numerical_question) { + FactoryGirl.create(:question, + :numerical_response, + { question_text: 'Do you like tacos?' }) + } + let!(:numerical_answer) { + FactoryGirl.create(:answer, + :numerical_response, + question: numerical_question, + numerical_response: 1, + call: call) + } + + let!(:voice_question) { + FactoryGirl.create(:question, + :voice_file, + question_text: 'What about chimichangas?') + } + let!(:voice_answer) { + FactoryGirl.create(:answer, + :voice_file, + question: voice_question, + voice_file_url: 'rant.mp3', + call: call) + } + + it 'mentions the call id' do + visit '/export.csv' + expect(page).to have_content(export_data) + end +end diff --git a/spec/support/fixtures/valid_export.csv b/spec/support/fixtures/valid_export.csv new file mode 100644 index 0000000..7810a98 --- /dev/null +++ b/spec/support/fixtures/valid_export.csv @@ -0,0 +1,2 @@ +Call ID,Location,Do you like tacos?,What about chimichangas? +456,El Farolito,Agree,rant.mp3