Sha256: 3540d1a339521280b5bc9c8fab6196afed772b057250a5612b4f1ddb483185b3

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

require 'date'

RSpec.describe SoapyBing::Ads::Reports::CampaignPerformanceReport do
  let(:report_options) { { oauth_credentials: nil, account: nil } }
  subject { described_class.new report_options }

  describe '#initialize' do
    let(:wrong_date) { 'wrong_date' }

    context 'when there is a wrong date format' do
      before { report_options.merge!(date_start: wrong_date) }

      let(:start_date) { 'wrong_date' }
      it 'throws exception' do
        expect { subject }.to raise_error(ArgumentError, 'invalid date')
      end
    end
  end

  describe '#date_range' do
    let(:date_start) { '2011-01-01' }
    let(:date_end) { '2015-12-31' }
    before { report_options.merge!(date_start: date_start, date_end: date_end) }

    it 'is instance of Range' do
      expect(subject.date_range).to be_an_instance_of Range
    end

    context 'begin' do
      it 'keeps initialized value' do
        expect(subject.date_range.begin).to eq Date.parse(date_start)
      end
    end

    context 'end' do
      it 'keeps initialized value' do
        expect(subject.date_range.end).to eq Date.parse(date_end)
      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/campaign_performance_report_spec.rb
soapy_bing-0.0.3 spec/soapy_bing/ads/reports/campaign_performance_report_spec.rb
soapy_bing-0.0.2 spec/soapy_bing/ads/reports/campaign_performance_report_spec.rb
soapy_bing-0.0.1 spec/soapy_bing/ads/reports/campaign_performance_report_spec.rb