Sha256: 7c080b57094bf19eacd9e1e9458552fa73c8e32ef21bf3363941fbded8a00ce4

Contents?: true

Size: 1.67 KB

Versions: 28

Compression:

Stored size: 1.67 KB

Contents

# frozen_string_literal: true

require 'spec_helpers/client'

RSpec.describe FinApps::REST::AlertOccurrences do
  include SpecHelpers::Client
  subject { FinApps::REST::AlertOccurrences.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) do
        {
          page: 2,
          sort: '-created_date',
          requested: 25,
          portfolio_id: 'valid_id'
        }
      end

      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/alerts/occurrences?" \
            'filter=%7B%22portfolio_id%22:%22valid_id%22%7D&page=2&requested=25&sort=-created_date'
        expect(WebMock).to have_requested(:get, url)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
finapps-5.0.32 spec/rest/alert_occurrences_spec.rb
finapps-5.0.31 spec/rest/alert_occurrences_spec.rb
finapps-5.0.30 spec/rest/alert_occurrences_spec.rb
finapps-5.0.29 spec/rest/alert_occurrences_spec.rb
finapps-5.0.28 spec/rest/alert_occurrences_spec.rb
finapps-5.0.27 spec/rest/alert_occurrences_spec.rb
finapps-5.0.26 spec/rest/alert_occurrences_spec.rb
finapps-5.0.25 spec/rest/alert_occurrences_spec.rb
finapps-5.0.24 spec/rest/alert_occurrences_spec.rb
finapps-5.0.23 spec/rest/alert_occurrences_spec.rb
finapps-5.0.22 spec/rest/alert_occurrences_spec.rb
finapps-5.0.21 spec/rest/alert_occurrences_spec.rb
finapps-5.0.20 spec/rest/alert_occurrences_spec.rb
finapps-5.0.19 spec/rest/alert_occurrences_spec.rb
finapps-5.0.17 spec/rest/alert_occurrences_spec.rb
finapps-5.0.16 spec/rest/alert_occurrences_spec.rb
finapps-5.0.15 spec/rest/alert_occurrences_spec.rb
finapps-5.0.14 spec/rest/alert_occurrences_spec.rb
finapps-5.0.13 spec/rest/alert_occurrences_spec.rb
finapps-5.0.12 spec/rest/alert_occurrences_spec.rb