spec/rest/sessions_spec.rb in finapps-5.0.3 vs spec/rest/sessions_spec.rb in finapps-5.0.4

- old
+ new

@@ -1,10 +1,11 @@ # frozen_string_literal: true require 'spec_helpers/client' -RSpec.describe FinApps::REST::Sessions, 'initialized with valid FinApps::Client object' do +RSpec.describe FinApps::REST::Sessions, + 'initialized with valid FinApps::Client object' do include SpecHelpers::Client subject { FinApps::REST::Sessions.new(client) } describe '#create' do let(:create) { subject.create(credentials) } @@ -12,42 +13,63 @@ 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(FinAppsCore::InvalidArgumentsError, message) + expect do + subject.create(email: nil, password: 'password') + end.to raise_error(FinAppsCore::InvalidArgumentsError, message) end it do - expect { subject.create(email: 'email', password: nil) } - .to raise_error(FinAppsCore::InvalidArgumentsError, message) + expect { subject.create(email: 'email', password: nil) }.to raise_error( + FinAppsCore::InvalidArgumentsError, + message + ) end end context 'for invalid credentials' do - let(:credentials) { { email: 'email@domain.com', password: 'invalid_password' } } + let(:credentials) do + { email: 'email@domain.com', password: 'invalid_password' } + end it { expect { create }.not_to raise_error } it('results is nil') { expect(results).to be_nil } error_message = 'Invalid Consumer Identifier or Credentials' - it('error_messages are populated') { expect(error_messages.first).to eq(error_message) } + it('error_messages are populated') do + expect(error_messages.first).to eq(error_message) + end end context 'for valid credentials' do - let(:credentials) { { email: 'email@domain.com', password: 'valid_password' } } + let(:credentials) do + { email: 'email@domain.com', password: 'valid_password' } + end - it('results is a Hashie::Rash') { expect(results).to be_a(Hashie::Mash::Rash) } - it('token value is in the result') { expect(results).to respond_to(:token) } + it('results is a Hashie::Rash') do + expect(results).to be_a(Hash) + end + it('token value is in the result') do + expect(results).to have_key(:token) + end it('error_messages is empty') { expect(error_messages).to be_empty } end context 'for valid credentials & path argument' do let(:create) { subject.create(credentials, 'operators/login') } - let(:credentials) { { email: 'email@domain.com', password: 'valid_password' } } + let(:credentials) do + { email: 'email@domain.com', password: 'valid_password' } + end - it('results is a Hashie::Rash') { expect(results).to be_a(Hashie::Mash::Rash) } - it('token value is in the result') { expect(results).to respond_to(:token) } - it('returns operator for operator path') { expect(results).to respond_to(:role) } + it('results is a Hashie::Rash') do + expect(results).to be_a(Hash) + end + it('token value is in the result') do + expect(results).to have_key(:token) + end + it('returns operator for operator path') do + expect(results).to have_key(:role) + end it('error_messages is empty') { expect(error_messages).to be_empty } end end describe '#destroy' do