spec/functional/cli_spec.rb in meetupinator-0.6.2 vs spec/functional/cli_spec.rb in meetupinator-0.7

- old
+ new

@@ -22,17 +22,46 @@ end context 'no arguments' do end + def prepare_html_for_comparison(html) + # Replace consecutive spaces with a single space, remove leading spaces at the start of a line, remove multiple blank lines + html.gsub(/[ ]+/, ' ').gsub(/^[ ]+/, '').gsub(/\n+/, "\n") + end + context 'meetup api and input file specified' do it 'generates the correct output.csv in the working dir' do VCR.use_cassette('functional') do Meetupinator::CLI.start(['-i', 'input.txt', '-k', '1234']) end - expect(CSV.read('output.csv')).to eq(CSV.read('../spec/fixtures/functional.csv')) + expect(CSV.read('output.csv')).to eq(CSV.read('../spec/fixtures/retrieveOutput.csv')) end end context 'meetup api and input file and output file specified' do + it 'generates the correct output in the specified location' do + VCR.use_cassette('functional') do + Meetupinator::CLI.start(['-i', 'input.txt', '-o', 'outputDir/mySpecialOutput.csv', '-k', '1234']) + end + expect(CSV.read('outputDir/mySpecialOutput.csv')).to eq(CSV.read('../spec/fixtures/retrieveOutput.csv')) + end + end + + context 'formatting output' do + it 'generates the correct output in the specified location' do + Meetupinator::CLI.start(['format', '-i', '../spec/fixtures/formatInput.csv', + '-o', 'outputDir/formattedOutput.md', + '-t', '../files/templates/default.html.erb']) + output = prepare_html_for_comparison(IO.read('outputDir/formattedOutput.md')) + expected_output = prepare_html_for_comparison(IO.read('../spec/fixtures/formatOutput.html')) + expect(output).to eq(expected_output) + end + + it 'generates the correct output in the default location using the default template' do + Meetupinator::CLI.start(['format', '-i', '../spec/fixtures/formatInput.csv']) + output = prepare_html_for_comparison(IO.read('output.html')) + expected_output = prepare_html_for_comparison(IO.read('../spec/fixtures/formatOutput.html')) + expect(output).to eq(expected_output) + end end end