Sha256: 86fd8cdc0e33ed63865592afa75798b94a5915351e40dc8f915a8c0c48bb4b02
Contents?: true
Size: 622 Bytes
Versions: 18
Compression:
Stored size: 622 Bytes
Contents
module SpecHelpers module Wait # Wait before the value of the "before" Proc becomes "becomes", # but only wait until "duration" number of seconds, # while checking the value each "interval" seconds interval. def wait(duration: 5.seconds, interval: (0.5).second, before:, becomes:) # use a different thread to prevent blocking the main thread due to sleep() Thread.new do start = Time.now loop do break if becomes.call(before.call) sleep interval.seconds break if (Time.now - start).seconds > duration end end.join end end end
Version data entries
18 entries across 18 versions & 1 rubygems