require 'time'

module WaitUtils
  def wait_until(wait = 3)
    timeout = Time.new + wait
    while Time.new < timeout
      return if yield
    end
    raise "Element not visible within #{wait} seconds"
  end
end
