Sha256: 5a2c9df709864e29ca6dfe2da2cbcfad9fe8241255e17de64bc8303211124162

Contents?: true

Size: 533 Bytes

Versions: 13

Compression:

Stored size: 533 Bytes

Contents

# frozen_string_literal: true

module PageMagic
  # module WaitMethods - contains methods for waiting
  module WaitMethods
    # Wait until a the supplied block returns true
    # @example
    #   wait_until do
    #     (rand % 2) == 0
    #   end
    def wait_until(timeout_after: 5, retry_every: 1, &_block)
      start_time = Time.now
      until Time.now > start_time + timeout_after
        return true if yield == true

        sleep retry_every
      end
      raise TimeoutException, 'Action took to long'
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
page_magic-2.0.13 lib/page_magic/wait_methods.rb
page_magic-2.0.12 lib/page_magic/wait_methods.rb
page_magic-2.0.11 lib/page_magic/wait_methods.rb
page_magic-2.0.10 lib/page_magic/wait_methods.rb
page_magic-2.0.9 lib/page_magic/wait_methods.rb
page_magic-2.0.6 lib/page_magic/wait_methods.rb
page_magic-2.0.5 lib/page_magic/wait_methods.rb
page_magic-2.0.4 lib/page_magic/wait_methods.rb
page_magic-2.0.3 lib/page_magic/wait_methods.rb
page_magic-2.0.2 lib/page_magic/wait_methods.rb
page_magic-2.0.1 lib/page_magic/wait_methods.rb
page_magic-2.0.0 lib/page_magic/wait_methods.rb
page_magic-2.0.0.alpha1 lib/page_magic/wait_methods.rb