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-1.1.1 spec/onfido/request_error_spec.rb
onfido-0.15.1 spec/onfido/request_error_spec.rb
onfido-1.1.0 spec/onfido/request_error_spec.rb
onfido-1.0.0 spec/onfido/request_error_spec.rb
onfido-0.15.0 spec/onfido/request_error_spec.rb
onfido-0.14.0 spec/onfido/request_error_spec.rb
onfido-0.13.0 spec/onfido/request_error_spec.rb
onfido-0.12.0 spec/onfido/request_error_spec.rb
onfido-0.11.0 spec/onfido/request_error_spec.rb
onfido-0.10.0 spec/onfido/request_error_spec.rb
onfido-0.9.0 spec/onfido/request_error_spec.rb
onfido-0.8.4 spec/onfido/request_error_spec.rb
onfido-0.8.3 spec/onfido/request_error_spec.rb
onfido-0.8.2 spec/onfido/request_error_spec.rb
onfido-0.8.1 spec/onfido/request_error_spec.rb
onfido-0.7.1 spec/onfido/request_error_spec.rb
onfido-0.7.0 spec/onfido/request_error_spec.rb
onfido-0.6.1 spec/onfido/request_error_spec.rb
onfido-0.6.0 spec/onfido/request_error_spec.rb
onfido-0.5.0 spec/onfido/request_error_spec.rb