Sha256: c89796f16a273281c04ec396dc15b07ada850a6f397c0b7940cd931dfc972e21

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Spearly::Auth::Client do
  let!(:connection_double) { instance_double(Faraday::Connection) }

  before do
    stub_const('ENV', { 'SPEARLY_API_URL' => 'https://api.spearly.test' })

    allow(Faraday).to receive(:new).and_return(connection_double)
  end

  it 'raises ServerError on Faraday::ConnectionFailed' do
    allow(connection_double).to receive(:run_request).and_raise(Faraday::ConnectionFailed.new('Failed to open TCP connection to :80'))

    expect do
      described_class.new('token')
                     .run_request(:method => :get, path: '/connection_failed')
    end.to raise_error(Spearly::Auth::ServerError, 'Failed to open TCP connection to :80')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spearly-sdk-ruby-0.11.0 spec/spearly/auth/client_spec.rb