Sha256: fac081e57caf7a5bc940711b4a52c3eaa34f86155e50934a4d20c33abc96679f

Contents?: true

Size: 1.79 KB

Versions: 24

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

require 'spec_helpers/client'

RSpec.describe FinApps::REST::ConsumersPortfolios do
  include SpecHelpers::Client
  subject { described_class.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') do
        expect(results).to have_key(:records)
      end

      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') do
        expect(results).to have_key(:records)
      end

      it('returns no error messages') { expect(errors).to be_empty }

      it 'builds query and sends proper request' do
        list
        url =
          "#{versioned_api_path}/consumers/#{id}/portfolios?page=2&" \
          'requested=25&sort=-created_date'
        expect(WebMock).to have_requested(:get, url)
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
finapps-6.13.1 spec/rest/consumers_portfolios_spec.rb
finapps-6.13.0 spec/rest/consumers_portfolios_spec.rb
finapps-6.12.0 spec/rest/consumers_portfolios_spec.rb
finapps-6.11.0 spec/rest/consumers_portfolios_spec.rb
finapps-6.10.2 spec/rest/consumers_portfolios_spec.rb
finapps-6.10.1 spec/rest/consumers_portfolios_spec.rb
finapps-6.10.0 spec/rest/consumers_portfolios_spec.rb
finapps-6.9.2 spec/rest/consumers_portfolios_spec.rb
finapps-6.9.1 spec/rest/consumers_portfolios_spec.rb
finapps-6.9.0 spec/rest/consumers_portfolios_spec.rb
finapps-6.8.0 spec/rest/consumers_portfolios_spec.rb
finapps-6.7.1 spec/rest/consumers_portfolios_spec.rb
finapps-6.7.0 spec/rest/consumers_portfolios_spec.rb
finapps-6.6.1 spec/rest/consumers_portfolios_spec.rb
finapps-6.6.0 spec/rest/consumers_portfolios_spec.rb
finapps-6.5.0 spec/rest/consumers_portfolios_spec.rb
finapps-6.4.3 spec/rest/consumers_portfolios_spec.rb
finapps-6.4.2 spec/rest/consumers_portfolios_spec.rb
finapps-6.4.1 spec/rest/consumers_portfolios_spec.rb
finapps-6.4.0 spec/rest/consumers_portfolios_spec.rb