The way this test should actually work is something like:

```ruby
let(:haproxy_show_stat) do
  begin
    UNIXSocket.open('/var/run/haproxy.sock') do |socket|
      socket.puts('show stat')
      CSV.parse(socket.read)
    end
  rescue Errno::EPIPE
    retry
  end
end
```

That will get the HAproxy data we need to do checks with and more specifically handle the broken pipe which seems to be what you were trying to handle below.

Then, the `it` blocks just need to check that `haproxy_show_stat` includes the right stuff.