Skip to content

Instantly share code, notes, and snippets.

@cblavier
Created March 5, 2015 17:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cblavier/5e15791387a6e22b98d8 to your computer and use it in GitHub Desktop.
Save cblavier/5e15791387a6e22b98d8 to your computer and use it in GitHub Desktop.
TimeHelper
defmodule TimeHelper do
def wait_until(fun), do: wait_until(500, fun)
def wait_until(0, fun), do: fun.()
def wait_until(timeout, fun) defo
try do
fun.()
rescue
ExUnit.AssertionError ->
:timer.sleep(10)
wait_until(max(0, timeout - 10), fun)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment