def simulate_disconnect(connection, reconnects_after = 2)
    connection.beanstalk.connection.connection.expects(:closed? => true)
    returns = Array.new(reconnects_after - 1, stub('TCPSocket'))
    returns.each do |socket|
      result = (socket != returns.last)
      socket.stubs(:closed? => result)
    end
    TCPSocket.expects(:new).times(returns.size).returns(*returns)
  end
Simulates a broken connection for any Beaneater::Connection. Will
simulate a restored connection after `reconnects_after`. This is expected
to be used when ensuring a Beaneater connection is open, therefore