summaryrefslogtreecommitdiff
path: root/spec/support/wait_for_ajax.rb
blob: 692d219e9f1ffa16bd7023df43f4305c1d8f8492 (plain)
1
2
3
4
5
6
7
8
9
10
11
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