Sha256: ba12e79692494d8d942f15c105a9dee9ceed6243fd09d0a421483667eb051edf

Contents?: true

Size: 1.54 KB

Versions: 17

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true
require 'spec_helpers/client'

RSpec.describe FinApps::REST::Sessions, 'initialized with valid FinApps::Client object' do
  include SpecHelpers::Client

  describe '#create' do
    subject { FinApps::REST::Sessions.new(client) }
    let(:create) { subject.create(credentials) }
    let(:results) { create[0] }
    let(:error_messages) { create[1] }

    context 'when missing email or password' do
      message = 'Invalid argument: params.'
      it do
        expect { subject.create(email: nil, password: 'password') }
          .to raise_error(FinApps::InvalidArgumentsError, message)
      end
      it do
        expect { subject.create(email: 'email', password: nil) }
          .to raise_error(FinApps::InvalidArgumentsError, message)
      end
    end

    context 'for invalid credentials' do
      let(:credentials) { {email: 'email@domain.com', password: 'invalid_password'} }

      it { expect { create }.not_to raise_error }
      it('results is nil') { expect(results).to be_nil }
      error_message = 'Invalid User Identifier or Credentials'
      it('error_messages are populated') { expect(error_messages.first).to eq(error_message) }
    end

    context 'for valid credentials' do
      let(:credentials) { {email: 'email@domain.com', password: 'valid_password'} }

      it('results is a Hashie::Rash') { expect(results).to be_a(Hashie::Rash) }
      it('token value is in the result') { expect(results).to respond_to(:token) }
      it('error_messages is empty') { expect(error_messages).to be_empty }
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
finapps-2.1.4 spec/rest/sessions_spec.rb
finapps-2.1.3 spec/rest/sessions_spec.rb
finapps-2.1.2 spec/rest/sessions_spec.rb
finapps-2.1.1 spec/rest/sessions_spec.rb
finapps-2.0.30 spec/rest/sessions_spec.rb
finapps-2.0.29 spec/rest/sessions_spec.rb
finapps-2.0.28 spec/rest/sessions_spec.rb
finapps-2.0.27 spec/rest/sessions_spec.rb
finapps-2.0.26 spec/rest/sessions_spec.rb
finapps-2.0.25 spec/rest/sessions_spec.rb
finapps-2.0.24 spec/rest/sessions_spec.rb
finapps-2.0.23 spec/rest/sessions_spec.rb
finapps-2.0.22 spec/rest/sessions_spec.rb
finapps-2.0.21 spec/rest/sessions_spec.rb
finapps-2.0.20 spec/rest/sessions_spec.rb
finapps-2.0.19 spec/rest/sessions_spec.rb
finapps-2.0.17 spec/rest/sessions_spec.rb