Newer
Older
dmpopidor / spec / support / wait_for_ajax.rb
@Bodacious Bodacious on 30 Jul 2018 355 bytes Add framework for RSpec integration tests
# frozen_string_literal: true

module WaitForAjax
  def wait_for_ajax
    Timeout.timeout(Capybara.default_max_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: :system)
end