Skip to content

Instantly share code, notes, and snippets.

@tomlea
Created April 7, 2009 15:08
Show Gist options
  • Select an option

  • Save tomlea/91277 to your computer and use it in GitHub Desktop.

Select an option

Save tomlea/91277 to your computer and use it in GitHub Desktop.
# The data setup inside the block may take upto a second to be ready to pass the test. But probably much less.
def retrying_for(secconds = 1)
limit = Time.now + secconds
begin
yield
rescue
if Time.now < limit
sleep 0.05
retry
else
raise
end
end
end
def test_should_update_via_queue
@queue.push("Some foo")
retrying_for(1.second) do # Data may not be updated right away, so give this test a second or so to run
assert_equal 1, get_some_foo_count_via_api
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment