-
-
Save joshuaclayton/64098 to your computer and use it in GitHub Desktop.
This file contains 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
Webrat.configure do |config| | |
config.mode = :selenium | |
end | |
class Cucumber::Rails::World | |
def wait_for_ajax(timeout = 15000) | |
selenium.wait_for_condition "window.Ajax.activeRequestCount == 0", timeout | |
end | |
def wait_for_effects(timeout = 15000) | |
selenium.wait_for_condition "window.Effect.Queue.size() == 0", timeout | |
end | |
def wait_for_ajax_and_effects | |
wait_for_ajax | |
wait_for_effects | |
end | |
end | |
After do | |
visit logout_path | |
# TODO: Why doesn't this work? | |
# $browser.delete_all_visible_cookies | |
# | |
# $browser.get_all_window_names[1..-1].each do |window| | |
# $browser.select_window window | |
# $browser.close | |
# end | |
# | |
# $browser.select_window nil | |
# Some deletes fail because of foreign key constraints. Catch any failures and try then again. Eventually it will work out. | |
classes = ActiveRecord::Base.send(:subclasses).select(&:table_exists?) | |
while classes.size > 0 | |
begin | |
classes.first.delete_all | |
classes.shift | |
rescue | |
classes << classes.shift | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment