Skip to content

Instantly share code, notes, and snippets.

@zdennis
Created February 13, 2009 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zdennis/64058 to your computer and use it in GitHub Desktop.
Save zdennis/64058 to your computer and use it in GitHub Desktop.
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