Sha256: 88df85c06bf1266626362065423b15a9447497903745549d259cd20e3d7a7893

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

RSpec.describe SoapyCake::Affiliate do
  subject { described_class.new(api_key: 'abc', affiliate_id: 1) }

  let(:client) { double('soap client') }

  describe '#bills' do
    it 'returns bills' do
      expect(SoapyCake::Client::CakeClient).to receive(:reports)
        .with(role: :affiliates)
        .and_return(client)

      expect(client).to receive(:bills).with(affiliate_id: 1, api_key: 'abc')

      subject.bills
    end
  end

  describe '#offer_feed' do
    let(:offers) { double('offers') }

    it 'returns offers' do
      expect(SoapyCake::Client::CakeClient).to receive(:offers)
        .with(role: :affiliates)
        .and_return(client)

      expect(client).to receive(:offer_feed)
        .with(affiliate_id: 1, api_key: 'abc', status_id: 3)
        .and_return(offers)

      expect(subject.offer_feed(status_id: 3)).to eq(offers)
    end
  end

  describe '#campaign' do
    let(:campaign) { double('campaign') }

    it 'returns a campaign' do
      expect(SoapyCake::Client::CakeClient).to receive(:offers)
        .with(role: :affiliates)
        .and_return(client)

      expect(client).to receive(:get_campaign)
        .with(affiliate_id: 1, api_key: 'abc', campaign_id: 12)
        .and_return(campaign)
      expect(subject.campaign(campaign_id: 12)).to eq(campaign)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
soapy_cake-0.3.4 spec/lib/soapy_cake/affiliate_spec.rb
soapy_cake-0.3.3 spec/lib/soapy_cake/affiliate_spec.rb
soapy_cake-0.3.2 spec/lib/soapy_cake/affiliate_spec.rb
soapy_cake-0.3.1 spec/lib/soapy_cake/affiliate_spec.rb