def wait_until(timeout=10)
      time_to_stop = Time.now + timeout
      while true
        rval = yield
        return rval if rval
        raise TimeoutError, "timeout of #{timeout}s exceeded" if Time.now > time_to_stop
        Thread.pass
      end
    end
def wait_until(timeout=10)
      time_to_stop = Time.now + timeout
      while true
        rval = yield
        return rval if rval
        raise TimeoutError, "timeout of #{timeout}s exceeded" if Time.now > time_to_stop
        Thread.pass
      end
    end
method to wait until block passed returns true or timeout (default is 10 seconds) is reached
 raises TiemoutError on timeout