From 4a15ccde3270016096c7a49ce007dc991c5543f7 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 30 Jul 2012 13:25:30 +0200 Subject: [PATCH] Run second waitFor in runs() block It seems that this is more reliable way to handle async waits. runs block is executed only when first waitFor succeeds and then it waits for next waitFor. --- assets/javascripts/spec/build_spec.coffee | 3 ++- public/javascripts/specs/specs.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/spec/build_spec.coffee b/assets/javascripts/spec/build_spec.coffee index c6e6bcec..c854761f 100644 --- a/assets/javascripts/spec/build_spec.coffee +++ b/assets/javascripts/spec/build_spec.coffee @@ -2,7 +2,8 @@ describe 'on the "build" state', -> beforeEach -> app 'travis-ci/travis-core/builds/1' waitFor reposRendered - waitFor buildRendered + runs -> + waitFor buildRendered afterEach -> window.history.pushState({}, null, '/spec.html') diff --git a/public/javascripts/specs/specs.js b/public/javascripts/specs/specs.js index 5c0c2c58..168cbe41 100644 --- a/public/javascripts/specs/specs.js +++ b/public/javascripts/specs/specs.js @@ -4,7 +4,9 @@ beforeEach(function() { app('travis-ci/travis-core/builds/1'); waitFor(reposRendered); - return waitFor(buildRendered); + return runs(function() { + return waitFor(buildRendered); + }); }); afterEach(function() { return window.history.pushState({}, null, '/spec.html');