Skip to content

Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬

708 B
Raw Blame
require 'rails_helper'

RSpec.describe DataImports::Intercom::Client do
  let(:client) { described_class.new(access_token: 'intercom-token') }

  describe '#list_contacts' do
    it 'wraps transport failures in a retryable client error', :aggregate_failures do
      allow(HTTParty).to receive(:get).and_raise(SocketError, 'getaddrinfo failed')

      expect { client.list_contacts }.to raise_error do |error|
        expect(error.class.name).to eq('DataImports::Intercom::Client::Error')
        expect(error.message).to eq('Intercom API request failed before receiving a response: getaddrinfo failed')
        expect(error.body).to include(transport_error_class: 'SocketError')
      end
    end
  end
end