Browse Source

Maintenance: until_constant browser test helper method does not actually performs a Timout and can't handle nil as a result.

Thorsten Eckel 4 years ago
parent
commit
c6e11f3f4e
1 changed files with 9 additions and 2 deletions
  1. 9 2
      spec/support/capybara/browser_test_helper.rb

+ 9 - 2
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