2015-11-17 11:22:29 +01:00
|
|
|
module WaitForAjax
|
|
|
|
def wait_for_ajax
|
2016-11-14 17:50:06 +01:00
|
|
|
Timeout.timeout(Capybara.default_max_wait_time) do
|
2015-11-17 11:22:29 +01:00
|
|
|
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
|