From c6e11f3f4e4d673b487dc946268c4483a7168ffc Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Wed, 23 Sep 2020 12:07:46 +0200 Subject: [PATCH] Maintenance: until_constant browser test helper method does not actually performs a Timout and can't handle nil as a result. --- spec/support/capybara/browser_test_helper.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/support/capybara/browser_test_helper.rb b/spec/support/capybara/browser_test_helper.rb index 6c3af7d17..54f8c8ee1 100644 --- a/spec/support/capybara/browser_test_helper.rb +++ b/spec/support/capybara/browser_test_helper.rb @@ -122,9 +122,16 @@ module BrowserTestHelper # def until_constant previous = nil - loop do - sleep __getobj__.instance_variable_get(:@interval) + timeout = __getobj__.instance_variable_get(:@timeout) + interval = __getobj__.instance_variable_get(:@interval) + rounds = (timeout / interval).to_i + + rounds.times do + sleep interval + latest = yield + + next if latest.nil? break if latest == previous previous = latest