Created
April 7, 2009 15:08
-
-
Save tomlea/91277 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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