Sha256: 66386349ddc5b2964be17434ec602f5f18ee4589418dbf89d3a8e06ebe8a0e41
Contents?: true
Size: 1.2 KB
Versions: 8
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true RSpec.describe FinAppsCore::Middleware::RaiseError do let(:fake_app) { proc {|env| env } } Env = Struct.new(:status, :response_headers, :body) describe '#on_complete' do subject { FinAppsCore::Middleware::RaiseError.new(fake_app) } context 'for successful requests' do let(:env) { Env.new(200) } it { expect { subject.on_complete(env) }.not_to raise_error } end context 'for client errors' do let(:env) { Env.new(401, {}, '{"messages":["Invalid User Identifier or Credentials"]}') } error_message = 'the server responded with status 401' it { expect { subject.on_complete(env) }.to raise_error(Faraday::Error::ClientError, error_message) } end context 'for connection failed error' do let(:env) { Env.new(407) } error_message = 'Connection Failed' it { expect { subject.on_complete(env) }.to raise_error(FinAppsCore::ConnectionFailedError, error_message) } end context 'for connection failed error' do let(:env) { Env.new(419) } error_message = 'Api Session Timed out' it { expect { subject.on_complete(env) }.to raise_error(FinAppsCore::ApiSessionTimeoutError, error_message) } end end end
Version data entries
8 entries across 8 versions & 1 rubygems