Sha256: 069604c20b99804d91b04173a0e76f70fe74f27a827269d5a2cf429baf655605

Contents?: true

Size: 900 Bytes

Versions: 4

Compression:

Stored size: 900 Bytes

Contents

require 'json'
require 'csv'

RSpec.describe SoapyBing::Ads::Reports::Parsers::CSVParser do
  describe '#rows' do
    subject { described_class.new(csv_data).rows }
    context 'on valid CSV data' do
      let(:csv_fixture_path) do
        File.join('spec', 'fixtures', 'reports', 'campaign_performance_report.csv')
      end
      let(:csv_data) { File.read(csv_fixture_path) }

      let(:json_fixture_path) do
        File.join('spec', 'fixtures', 'reports', 'campaign_performance_report.json')
      end
      let(:json_data) { JSON.load(File.read(json_fixture_path)) }

      it 'responds with array of Hashes' do
        expect(subject).to eq json_data
      end
    end

    context 'on malformed CSV data 'do
      let(:csv_data) { '"co", "' }

      it 'throws exception CSV::MalformedCSVError' do
        expect { subject }.to raise_error CSV::MalformedCSVError
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
soapy_bing-0.0.4 spec/soapy_bing/ads/reports/parsers/csv_parser_spec.rb
soapy_bing-0.0.3 spec/soapy_bing/ads/reports/parsers/csv_parser_spec.rb
soapy_bing-0.0.2 spec/soapy_bing/ads/reports/parsers/csv_parser_spec.rb
soapy_bing-0.0.1 spec/soapy_bing/ads/reports/parsers/csv_parser_spec.rb