Sha256: fd636148c7922f181942f6bc817b5496e8401fc1258647ecd1f9a239f14ef2bb

Contents?: true

Size: 923 Bytes

Versions: 3

Compression:

Stored size: 923 Bytes

Contents

# frozen_string_literal: true

require 'json'
require 'csv'

RSpec.describe SoapyBing::Ads::Parsers::ReportCsvParser do
  describe '#rows' do
    subject(:rows) { described_class.new(csv_data).rows }

    context 'on valid CSV data' do
      let(:csv_fixture_path) do
        File.join('spec', 'fixtures', 'ads', 'campaign_performance_report.csv')
      end
      let(:csv_data) { File.read(csv_fixture_path) }

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

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
soapy_bing-1.0.1 spec/soapy_bing/ads/parsers/report_csv_parser_spec.rb
soapy_bing-1.0.0 spec/soapy_bing/ads/parsers/report_csv_parser_spec.rb
soapy_bing-0.4.0 spec/soapy_bing/ads/parsers/report_csv_parser_spec.rb