Created
February 24, 2012 11:04
-
-
Save natritmeyer/1900170 to your computer and use it in GitHub Desktop.
Fix for ajax problems in tests
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
module AjaxWaiter | |
def wait_for_ajax | |
wait_until { page.evaluate_script("jQuery.active") == 0 } | |
end | |
end | |
World(AjaxWaiter) |
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
Given /^I do something which kicks off an ajax transaction$/ do | |
click_link 'whatever' | |
#at this point the test used to die, but now it doesn't because we have... | |
wait_for_ajax | |
#the test continues - woohoo! | |
click_link 'something_else' #this line originally caused the test to die because it tried to execute whilst the browser was still talking with the server | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment