lib/appium_lib/common/wait.rb in appium_lib-9.1.1 vs lib/appium_lib/common/wait.rb in appium_lib-9.1.2
- old
+ new
@@ -4,11 +4,11 @@
# Note that the Ruby timeout module is avoided. timeout has problems.
# https://coderwall.com/p/1novga
# Wait code from the selenium Ruby gem
# https://github.com/SeleniumHQ/selenium/blob/cf501dda3f0ed12233de51ce8170c0e8090f0c20/rb/lib/selenium/webdriver/common/wait.rb
- def _generic_wait(opts = {}, &block)
+ def _generic_wait(opts = {})
valid_keys = [:timeout, :interval, :message, :ignore, :return_if_true]
invalid_keys = []
opts.keys.each { |key| invalid_keys << key unless valid_keys.include?(key) }
# [:one, :two] => :one, :two
raise "Invalid keys #{invalid_keys.to_s[1..-2]}. Valid keys are #{valid_keys.to_s[1..-2]}" unless invalid_keys.empty?
@@ -22,13 +22,13 @@
end_time = Time.now + timeout
last_error = nil
until Time.now > end_time
begin
- return block.call unless return_if_true
+ return yield unless return_if_true
- result = block.call
+ result = yield
return result if result
rescue ::Errno::ECONNREFUSED => e
raise e
rescue *ignored => last_error # rubocop:disable Lint/HandleExceptions
# swallowed
@@ -49,11 +49,11 @@
opts = { timeout: opts } if opts.is_a?(Numeric)
raise 'opts must be a hash' unless opts.is_a? Hash
opts
end
- # Check every interval seconds to see if block.call returns a truthy value.
+ # Check every interval seconds to see if yield returns a truthy value.
# Note this isn't a strict boolean true, any truthy value is accepted.
# false and nil are considered failures.
# Give up after timeout seconds.
#
# Wait code from the selenium Ruby gem
@@ -69,10 +69,10 @@
def wait_true(opts = {}, &block)
opts = _process_wait_opts(opts).merge(return_if_true: true)
_generic_wait opts, &block
end
- # Check every interval seconds to see if block.call doesn't raise an exception.
+ # Check every interval seconds to see if yield doesn't raise an exception.
# Give up after timeout seconds.
#
# Wait code from the selenium Ruby gem
# https://github.com/SeleniumHQ/selenium/blob/cf501dda3f0ed12233de51ce8170c0e8090f0c20/rb/lib/selenium/webdriver/common/wait.rb
#