Sha256: 5a570f25a64ceebe55755e517b6ff30358d8ac10eb736a6981cc0307c341a353

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require 'spec_helpers/client'

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

  let(:api_client) { client }
  subject(:create) { FinApps::REST::PlaidWebhooks.new(api_client).create }

  describe '#create' do
    RSpec.shared_examples 'an API request' do |_parameter|
      it { expect { create }.not_to raise_error }
      it('returns an array') { expect(create).to be_a(Array) }
    end

    context 'when valid tenant token is provided' do
      it_behaves_like 'an API request'

      it('performs a post and returns the webhook url') do
        expect(create[RESULTS]).to respond_to(:url)
      end
      it('returns no error messages') { expect(create[ERROR_MESSAGES]).to be_empty }
    end

    context 'when invalid tenant token is provided' do
      let(:api_client) { client(:invalid_tenant_token) }

      it_behaves_like 'an API request'
      it('results is nil') { expect(create[RESULTS]).to be_nil }
      it('error messages array is populated') do
        expect(create[ERROR_MESSAGES].first.downcase).to eq('resource not found')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
finapps-5.0.3 spec/rest/plaid/plaid_webhooks_spec.rb
finapps-5.0.2 spec/rest/plaid/plaid_webhooks_spec.rb
finapps-5.0.1 spec/rest/plaid/plaid_webhooks_spec.rb
finapps-5.0.0 spec/rest/plaid/plaid_webhooks_spec.rb