Sha256: fd96d29e7de1568292e9b59586333ee576ada495c12a936e5ff4a8ec17902f83

Contents?: true

Size: 1.82 KB

Versions: 6

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

require 'spec_helpers/client'
require 'rest/api_request'

RSpec.describe FinApps::REST::PlaidConsumerInstitutions do
  include SpecHelpers::Client

  # noinspection RubyBlockToMethodReference
  let(:api_client) { client }

  RSpec.shared_examples 'a request that returns institution data' do |_parameter|
    it('returns institution data') { expect(subject[RESULTS]).to have_key(:plaid_institution_id) }
  end

  describe '#create' do
    subject(:create) do
      FinApps::REST::PlaidConsumerInstitutions.new(api_client).create(
        public_token: 'le-token'
      )
    end

    it_behaves_like 'an API request'
    it_behaves_like 'a successful request'
    it_behaves_like 'a request that returns institution data'
  end

  describe '#show' do
    subject(:show) do
      FinApps::REST::PlaidConsumerInstitutions.new(api_client).show(
        :consumer_institution_id
      )
    end

    it_behaves_like 'an API request'
    it_behaves_like 'a successful request'
    it_behaves_like 'a request that returns institution data'
    context 'when requesting accounts information' do
      subject(:show) do
        FinApps::REST::PlaidConsumerInstitutions.new(api_client).show(
          :consumer_institution_id, show_accounts: true
        )
      end

      it_behaves_like 'an API request'
      it_behaves_like 'a successful request'
      it_behaves_like 'a request that returns institution data'
      it('returns institution account data') { expect(subject[RESULTS]).to have_key(:accounts) }
    end
  end

  describe '#list' do
    subject(:list) { FinApps::REST::PlaidConsumerInstitutions.new(api_client).list }

    it_behaves_like 'an API request'
    it_behaves_like 'a successful request'
    it('returns an Array of institution data') { expect(list[RESULTS].first).to have_key(:plaid_institution_id) }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
finapps-5.0.16 spec/rest/plaid/plaid_consumer_institutions_spec.rb
finapps-5.0.15 spec/rest/plaid/plaid_consumer_institutions_spec.rb
finapps-5.0.14 spec/rest/plaid/plaid_consumer_institutions_spec.rb
finapps-5.0.13 spec/rest/plaid/plaid_consumer_institutions_spec.rb
finapps-5.0.12 spec/rest/plaid/plaid_consumer_institutions_spec.rb
finapps-5.0.11 spec/rest/plaid/plaid_consumer_institutions_spec.rb