Sha256: 543d35561ea286cdca16224d506a11967b9d9862588758f24e0dda1cc65a054c

Contents?: true

Size: 997 Bytes

Versions: 6

Compression:

Stored size: 997 Bytes

Contents

# frozen_string_literal: true

RSpec.describe SoapyCake::Affiliate do
  let(:affiliate_id) { 42 }
  let(:opts) { { a: 1 } }
  let(:cake_opts) { opts.merge(affiliate_id: affiliate_id) }

  subject(:affiliate) { described_class.new(affiliate_id: affiliate_id) }

  shared_examples_for 'a cake affiliate method' do
    it 'runs the request' do
      request = instance_double(SoapyCake::Request)
      expect(SoapyCake::Request).to receive(:new)
        .with(:affiliate, service, method, cake_opts).and_return(request)
      # rubocop:disable RSpec/SubjectStub
      expect(affiliate).to receive(:run).with(request)
      # rubocop:enable RSpec/SubjectStub

      affiliate.public_send(method, opts)
    end
  end

  describe '#bills' do
    let(:service) { :reports }
    let(:method) { :bills }

    it_behaves_like 'a cake affiliate method'
  end

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

    it_behaves_like 'a cake affiliate method'
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
soapy_cake-2.3.1 spec/lib/soapy_cake/affiliate_spec.rb
soapy_cake-2.3.0 spec/lib/soapy_cake/affiliate_spec.rb
soapy_cake-2.2.7 spec/lib/soapy_cake/affiliate_spec.rb
soapy_cake-2.2.6 spec/lib/soapy_cake/affiliate_spec.rb
soapy_cake-2.2.5 spec/lib/soapy_cake/affiliate_spec.rb
soapy_cake-2.2.4 spec/lib/soapy_cake/affiliate_spec.rb