From c763d37d73efe91d8c14a972e62a6eef1c50ca01 Mon Sep 17 00:00:00 2001 From: Valery Kalashnikov Date: Wed, 22 Apr 2015 15:58:55 +0600 Subject: [PATCH] Added wait_for_ajax_method Sometimes Capybara.default_wait_time is not enough and build fails. --- spec/features/notes_spec.rb | 5 +++++ spec/features/stories_spec.rb | 2 ++ spec/support/integration_helpers.rb | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/spec/features/notes_spec.rb b/spec/features/notes_spec.rb index 952d7f01b..72f49d218 100644 --- a/spec/features/notes_spec.rb +++ b/spec/features/notes_spec.rb @@ -37,6 +37,8 @@ click_on 'Add note' end + wait_for_ajax + find('#in_progress .story .notelist .note').should have_content('Adding a new note') end @@ -54,6 +56,9 @@ click_on 'Delete' end end + + wait_for_ajax + find('#in_progress .story .notelist').should_not have_content('Delete me please') end diff --git a/spec/features/stories_spec.rb b/spec/features/stories_spec.rb index 6c05f857d..371d51d94 100644 --- a/spec/features/stories_spec.rb +++ b/spec/features/stories_spec.rb @@ -32,6 +32,8 @@ click_on 'Save' end + wait_for_ajax + # Estimate the story within('#chilly_bin .story') do click_on '1' diff --git a/spec/support/integration_helpers.rb b/spec/support/integration_helpers.rb index 54dd6e171..fcd9a47b9 100644 --- a/spec/support/integration_helpers.rb +++ b/spec/support/integration_helpers.rb @@ -40,4 +40,13 @@ def get_confirmation_token_from_mail(email) token end + def wait_for_ajax + Timeout.timeout(Capybara.default_wait_time) do + active = page.evaluate_script('jQuery.active') + until active == 0 + active = page.evaluate_script('jQuery.active') + end + end + end + end