Sha256: 26c18187e7d13be76e58e1050aa63b868e13a88615dd2e33d9f66f309a290a21

Contents?: true

Size: 1.82 KB

Versions: 12

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

require 'spec_helpers/client'

RSpec.describe FinApps::REST::PortfoliosAvailableConsumers do
  include SpecHelpers::Client
  subject { FinApps::REST::PortfoliosAvailableConsumers.new(client) }

  describe '#list' do
    let(:list) { subject.list(id, params) }
    let(:results) { list[RESULTS] }
    let(:errors) { list[ERROR_MESSAGES] }

    context 'when missing id' do
      let(:id) { nil }
      let(:params) { nil }

      it { expect { list }.to raise_error(FinAppsCore::MissingArgumentsError) }
    end

    context 'when missing params' do
      let(:id) { 'valid_id' }
      let(:params) { nil }

      it { expect { list }.not_to raise_error }
      it('returns an array') { expect(list).to be_a(Array) }
      it('performs a get and returns the response') { expect(results).to respond_to(:records) }
      it('returns no error messages') { expect(errors).to be_empty }
    end

    context 'when invalid params are provided' do
      let(:id) { 'valid_id' }
      let(:params) { %w[this is an array] }

      it { expect { list }.to raise_error(FinAppsCore::InvalidArgumentsError) }
    end

    context 'when including valid params' do
      let(:id) { 'valid_id' }
      let(:params) { { page: 2, sort: '-created_date', requested: 25 } }

      it { expect { list }.not_to raise_error }
      it('returns an array') { expect(list).to be_a(Array) }
      it('performs a get and returns the response') { expect(results).to respond_to(:records) }
      it('returns no error messages') { expect(errors).to be_empty }
      it 'builds query and sends proper request' do
        list
        url = "#{FinAppsCore::REST::Defaults::DEFAULTS[:host]}/v3/portfolios/#{id}/consumers/available?page=2&" \
        'requested=25&sort=-created_date'
        expect(WebMock).to have_requested(:get, url)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
finapps-5.0.2 spec/rest/portfolios_available_consumers_spec.rb
finapps-5.0.1 spec/rest/portfolios_available_consumers_spec.rb
finapps-5.0.0 spec/rest/portfolios_available_consumers_spec.rb
finapps-4.0.16 spec/rest/portfolios_available_consumers_spec.rb
finapps-4.0.15 spec/rest/portfolios_available_consumers_spec.rb
finapps-4.0.14 spec/rest/portfolios_available_consumers_spec.rb
finapps-4.0.12 spec/rest/portfolios_available_consumers_spec.rb
finapps-4.0.11 spec/rest/portfolios_available_consumers_spec.rb
finapps-4.0.10 spec/rest/portfolios_available_consumers_spec.rb
finapps-4.0.9 spec/rest/portfolios_available_consumers_spec.rb
finapps-4.0.8 spec/rest/portfolios_available_consumers_spec.rb
finapps-4.0.7 spec/rest/portfolios_available_consumers_spec.rb