Sha256: b069e925dac022d8e9f34733c32ced11188de646a78048e59fe933d665faf669

Contents?: true

Size: 1.52 KB

Versions: 18

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

require 'spec_helpers/client'

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

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

    context 'when missing params' do
      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(:params) { %w[this is an array] }

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

    context 'when including valid params' do
      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}/portfolio/reports?page=2&requested=25&" \
            'sort=-created_date'
        expect(WebMock).to have_requested(:get, url)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
finapps-6.0.0 spec/rest/portfolio_reports_spec.rb
finapps-5.4.1 spec/rest/portfolio_reports_spec.rb
finapps-5.4.0 spec/rest/portfolio_reports_spec.rb
finapps-5.3.0 spec/rest/portfolio_reports_spec.rb
finapps-5.2.1 spec/rest/portfolio_reports_spec.rb
finapps-5.2.0 spec/rest/portfolio_reports_spec.rb
finapps-5.1.0 spec/rest/portfolio_reports_spec.rb
finapps-5.0.47 spec/rest/portfolio_reports_spec.rb
finapps-5.0.46 spec/rest/portfolio_reports_spec.rb
finapps-5.0.45 spec/rest/portfolio_reports_spec.rb
finapps-5.0.44 spec/rest/portfolio_reports_spec.rb
finapps-5.0.43 spec/rest/portfolio_reports_spec.rb
finapps-5.0.41 spec/rest/portfolio_reports_spec.rb
finapps-5.0.38 spec/rest/portfolio_reports_spec.rb
finapps-5.0.36 spec/rest/portfolio_reports_spec.rb
finapps-5.0.35 spec/rest/portfolio_reports_spec.rb
finapps-5.0.34 spec/rest/portfolio_reports_spec.rb
finapps-5.0.33 spec/rest/portfolio_reports_spec.rb