lib/watir/legacy_wait.rb in watir-6.13.0 vs lib/watir/legacy_wait.rb in watir-6.14.0

- old
+ new

@@ -1,29 +1,26 @@ require 'forwardable' -# TODO - remove this file for future release +# TODO: - remove this file for future release module Watir - class BaseDecorator def initialize(element, timeout, message = nil) @element = element @timeout = timeout @message = message end - def respond_to?(*args) + def respond_to_missing?(*args) @element.respond_to?(*args) end - def method_missing(m, *args, &block) - unless @element.respond_to?(m) - raise NoMethodError, "undefined method `#{m}' for #{@element.inspect}:#{@element.class}" - end + def method_missing(method, *args, &block) + return super unless @element.respond_to?(method) Watir::Wait.until(@timeout, @message) { wait_until } - @element.__send__(m, *args, &block) + @element.__send__(method, *args, &block) end end # # Wraps an Element so that any subsequent method calls are @@ -49,11 +46,10 @@ # Wraps an Element so that any subsequent method calls are # put on hold until the element is enabled (exists and is enabled) on the page. # class WhenEnabledDecorator < BaseDecorator - private def wait_until @element.enabled? end @@ -81,11 +77,11 @@ # def when_present(timeout = nil) warning = '#when_present has been deprecated and is unlikely to be needed; ' warning << 'replace this with #wait_until_present if a wait is still needed' - Watir.logger.warn warning, ids: [:when_present, :deprecations] + Watir.logger.warn warning, ids: %i[when_present deprecations] timeout ||= Watir.default_timeout message = "waiting for #{selector_string} to become present" if block_given? @@ -108,11 +104,11 @@ # @see Watir::Element#enabled? # def when_enabled(timeout = nil) Watir.logger.warn '#when_enabled has been deprecated and is unlikely to be needed', - ids: [:when_enabled, :deprecations] + ids: %i[when_enabled deprecations] timeout ||= Watir.default_timeout message = "waiting for #{selector_string} to become enabled" if block_given? @@ -120,8 +116,7 @@ yield self else WhenEnabledDecorator.new(self, timeout, message) end end - end # EventuallyPresent end # Watir