| 
20 | 20 |       blocks_spy.second_block_called(f)  | 
21 | 21 |     end  | 
22 | 22 | 
 
  | 
23 |  | -    expect(Faraday).to receive(:new).and_yield(@connection).and_return(@connection)  | 
24 |  | -    allow_any_instance_of(Faraday::Connection).to receive(:send).and_return(double('response', status: 301, body: {}, headers: {}))  | 
 | 23 | +    allow(Faraday).to receive(:new).and_yield(@connection).and_return(@connection)  | 
 | 24 | +    allow(@connection).to receive(:send).and_return(double('response', status: 301, body: {}, headers: {}))  | 
25 | 25 | 
 
  | 
26 | 26 |     @client.request('host', 'port', 'GET', 'url', nil, nil, {}, ['a', 'b'])  | 
27 | 27 | 
 
  | 
28 | 28 |     expect(blocks_spy).to have_received(:first_block_called).with(@connection)  | 
29 | 29 |     expect(blocks_spy).to have_received(:second_block_called).with(@connection)  | 
30 | 30 |   end  | 
31 | 31 | 
 
  | 
 | 32 | +  it 'should allow the configuration block to set the connection adapter' do  | 
 | 33 | +    @client = Twilio::HTTP::Client.new  | 
 | 34 | +    @connection = Faraday::Connection.new  | 
 | 35 | + | 
 | 36 | +    stub_const('TestAdapter', Class.new(Faraday::Adapter))  | 
 | 37 | +    Faraday::Adapter.register_middleware test_adapter: TestAdapter  | 
 | 38 | + | 
 | 39 | +    @client.configure_connection do |f|  | 
 | 40 | +      f.adapter :test_adapter  | 
 | 41 | +    end  | 
 | 42 | + | 
 | 43 | +    allow(Faraday).to receive(:new).and_yield(@connection).and_return(@connection)  | 
 | 44 | +    allow(@connection).to receive(:send).and_return(double('response', status: 301, body: {}, headers: {}))  | 
 | 45 | + | 
 | 46 | +    @client.request('host', 'port', 'GET', 'url', nil, nil, {}, ['a', 'b'])  | 
 | 47 | + | 
 | 48 | +    expect(@connection.adapter).to eq TestAdapter  | 
 | 49 | +  end  | 
 | 50 | + | 
32 | 51 |   it 'should allow setting a global timeout' do  | 
33 | 52 |     @client = Twilio::HTTP::Client.new(timeout: 10)  | 
34 | 53 |     @connection = Faraday::Connection.new  | 
 | 
0 commit comments