Sha256: 08fa682e028da025b31b9c05569bb85ae9e372032557c5f8c66a642ee8b4897a
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 KB
Contents
describe Onfido::Resource do let(:resource) { described_class.new } let(:api_key) { 'some_key' } before { allow(Onfido).to receive(:api_key).and_return(api_key) } context '4xx response' do it 'raises a custom error' do path = '4xx_response' expect { resource.get(path: path) }. to raise_error(Onfido::RequestError, 'Something went wrong') end end context 'unexpected error format' do it 'raises a custom error' do path = 'unexpected_error_format' expect { resource.get(path: path) }. to raise_error(Onfido::RequestError, /response code was 400/) end end context 'unparseable JSON 5xx' do it 'raises a server error' do path = 'unparseable_response' expect { resource.get(path: path) }. to raise_error(Onfido::ServerError, /response code was 504/) end end context 'timeout' do before do allow(RestClient::Request). to receive(:execute). and_raise(RestClient::RequestTimeout) end it 'raises a ConnectionError' do expect { resource.get(path: Onfido.endpoint) }. to raise_error(Onfido::ConnectionError, /Could not connect/) end end context 'broken connection' do before do allow(RestClient::Request). to receive(:execute). and_raise(RestClient::ServerBrokeConnection) end it 'raises a ConnectionError' do expect { resource.get(path: Onfido.endpoint) }. to raise_error(Onfido::ConnectionError, /connection to the server/) end end context "bad SSL certificate" do before do allow(RestClient::Request). to receive(:execute). and_raise(RestClient::SSLCertificateNotVerified.new(nil)) end it 'raises a ConnectionError' do expect { resource.get(path: Onfido.endpoint) }. to raise_error(Onfido::ConnectionError, /SSL certificate/) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
onfido-1.1.1 | spec/integrations/exceptions_spec.rb |