Sha256: 6848ece26357a682b5ca2829b288ea4689e4f2e814d10d3df579046dff18ce22

Contents?: true

Size: 1001 Bytes

Versions: 24

Compression:

Stored size: 1001 Bytes

Contents

describe Onfido::RequestError do
  subject(:error) do
    described_class.new(
      failed_response['error']['message'],
      response_code: 401,
      response_body: failed_response.to_json
    )
  end

  let(:failed_response) do
    {
      'error' =>
      {
        'id' => '551722cc964860653c00c202',
        'type' => 'authorization_error',
        'message' => 'Authorization error: please re-check your credentials',
        'fields' => { 'name' => { 'messages' => ['cannot be blank'] } }
      }
    }
  end

  it 'returns the right message' do
    expect { raise error }.
      to raise_error('Authorization error: please re-check your credentials')
  end

  its(:type) { is_expected.to eq('authorization_error') }
  its(:response_code) { is_expected.to eq(401) }
  its(:response_body) { is_expected.to eq(failed_response.to_json) }
  its(:json_body) { is_expected.to eq(failed_response) }
  its(:fields) do
    is_expected.to eq('name' => { 'messages' => ['cannot be blank'] })
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
onfido-0.4.0 spec/onfido/request_error_spec.rb
onfido-0.3.0 spec/onfido/request_error_spec.rb
onfido-0.2.0 spec/onfido/request_error_spec.rb
onfido-0.1.0 spec/onfido/request_error_spec.rb