title: Webmock test for failure to connect fails before finishing test
body: <p>I have test to for connection error:</p>
  <pre><code>context 'unsuccessful API request' do
    it 'responds like 500 if connection error is raised' do
      http_stub = instance_double(Net::HTTP)
      allow(Net::HTTP).to receive(:new).and_return(http_stub)
      allow(http_stub).to receive(:request).and_raise(Errno::ECONNREFUSED)
  
      api_client = ApiClient.new
  
      api_client.create_implementer('Wayfarer')
  
      expect(api_client.response_status).to eq(500)
      expect(api_client.response_body).to eq({ issue' =&gt; [{ 'details' =&gt; { 'text' =&gt; 'Connection error' }}]})
    end
  end
  </code></pre>
  <p>And when I run it, it fails like it's supposed to but fails in the method instead of in the test so the test for the failure fails:</p>
  <pre><code>Failure/Error: response = http.request(request)
       
  Errno::ECONNREFUSED:
    Connection refused
  </code></pre>
  <p>Which is the correct error but it's failing in the method:</p>
  <pre><code>  def http_request(request, uri)
      http = Net::HTTP.new(uri.host, uri.port)
  
      response = http.request(request)
      @response_status = response.code.to_i
  
      if response_successful?
        @response_body = parsed_response(response)
      else
        @response_body = response.body rescue Errno::ECONNREFUSED
        connection_error
      end
    end
  </code></pre>
  <p>The issue is it's stopping in the middle of the <code>http_request</code> method at the line for <code>response = http.request(request)</code>. It doesn't follow through with the error handling.</p>
  <p>If I put a <code>binding.pry</code> after that line it isn't reached and the method just bails.</p>