Sha256: dfcda407dd6b2d219063040dd8372ddab0215798c00b408b4f0d4cad716e404e

Contents?: true

Size: 492 Bytes

Versions: 10

Compression:

Stored size: 492 Bytes

Contents

module Capybara
  class << self

    ##
    # Provides timeout similar to standard library Timeout, but avoids threads
    #
    def timeout(seconds = 1, driver = nil, &block)
      start_time = Time.now

      result = nil

      until result
        return result if result = yield

        delay = seconds - (Time.now - start_time)
        if delay <= 0
          raise TimeoutError
        end

        driver && driver.wait_until(delay)

        sleep(0.05)
      end
    end

  end
end

Version data entries

10 entries across 10 versions & 4 rubygems

Version Path
capybara-0.4.1.2 lib/capybara/util/timeout.rb
capybara-rails-2-2-0.4.1.1 lib/capybara/util/timeout.rb
rcarvalho-capybara-0.4.1.2 lib/capybara/util/timeout.rb
rcarvalho-capybara-0.4.1.1 lib/capybara/util/timeout.rb
capybara-0.4.1.1 lib/capybara/util/timeout.rb
capybara-0.4.1.rc lib/capybara/util/timeout.rb
yannp-capybara-0.4.0 lib/capybara/util/timeout.rb
capybara-0.4.0 lib/capybara/util/timeout.rb
capybara-0.4.0.rc lib/capybara/util/timeout.rb
yannp-capybara-0.3.9 lib/capybara/util/timeout.rb