Sha256: 9e4927ca5693f4ed2f1df70a9cb4357d34b6b0cb31ca9b6986dd9d6646612136

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true
require 'spec_helpers/client'

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

  RESULT = 0
  ERROR_MESSAGES = 1

  describe '#show' do
    context 'when missing site id' do
      subject { FinApps::REST::UserInstitutionsForms.new(client).show(nil) }
      it('raises missing argument error') { expect { subject }.to raise_error(FinAppsCore::MissingArgumentsError) }
    end

    context 'when valid site id provided' do
      subject { FinApps::REST::UserInstitutionsForms.new(client).show('valid_id') }

      it { expect { subject }.not_to raise_error }
      it('performs a get and returns the login html') { expect(subject[RESULT]).to respond_to(:login_form_html) }
      it('returns no error messages') { expect(subject[ERROR_MESSAGES]).to be_empty }
    end

    context 'when invalid site id provided' do
      subject { FinApps::REST::UserInstitutionsForms.new(client).show('invalid_id') }

      it { expect { subject }.not_to raise_error }
      it('results is nil') { expect(subject[RESULT]).to be_nil }
      it('error messages array is populated') { expect(subject[ERROR_MESSAGES].first.downcase).to eq('invalid institution id') }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
finapps-2.2.5 spec/rest/user_institutions_forms_spec.rb