Sha256: 04d8b24c2cab5b5767ec91ff7ff73407881ab2719f6f2086fcd7fe71d38326a1
Contents?: true
Size: 920 Bytes
Versions: 3
Compression:
Stored size: 920 Bytes
Contents
describe Onfido::Resource do let(:resource) { described_class.new } let(:url) { Onfido.endpoint + path } let(:api_key) { 'some_key' } let(:payload) { {postcode: 'SE1 4NG'} } before do allow(Onfido).to receive(:api_key).and_return(api_key) end context 'when a response is a 4xx' do let(:path) { '4xx_response' } context "when 'throws_exceptions' is true" do it 'raises a custom error' do expect { resource.get({url: url, payload: payload}) }.to raise_error( Onfido::RequestError, 'Something went wrong') end end context "when 'throws_exceptions' is false" do before do allow(Onfido).to receive(:throws_exceptions).and_return(false) end it 'returns the body as a hash' do response = resource.get({url: url, payload: payload}) expect(response['error']).not_to be_nil end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
onfido-0.0.3 | spec/integrations/4xx_response_spec.rb |
onfido-0.0.2 | spec/integrations/4xx_response_spec.rb |
onfido-0.0.1 | spec/integrations/4xx_response_spec.rb |