add support file to wait for ajax request for capybara tests

This commit is contained in:
Tanguy PATTE 2015-11-17 11:22:29 +01:00
parent 5a422c75ac
commit afd0b72ae8

View file

@ -0,0 +1,16 @@
# spec/support/wait_for_ajax.rb
module WaitForAjax
def wait_for_ajax
Timeout.timeout(Capybara.default_wait_time) do
loop until finished_all_ajax_requests?
end
end
def finished_all_ajax_requests?
page.evaluate_script('jQuery.active').zero?
end
end
RSpec.configure do |config|
config.include WaitForAjax, type: :feature
end