add support file to wait for ajax request for capybara tests
This commit is contained in:
parent
5a422c75ac
commit
afd0b72ae8
1 changed files with 16 additions and 0 deletions
16
spec/support/wait_for_ajax.rb
Normal file
16
spec/support/wait_for_ajax.rb
Normal 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
|
Loading…
Add table
Reference in a new issue