lib/testable/element.rb
# This predicate method checks if a given element is a valid element that
# Watir knows how to interact with, but in plural form.
#
# @example
#   Testable.recognizes?(:spans) # => true
#   Testable.recognizes?(:divs) # => true
#   Testable.recognizes?(:class) # => false
#   Testable.recognizes?(:classes) # => false
This predicate method checks if a given element is a valid element that
Watir knows how to interact with, but in plural form.
This predicate method checks if a given element is a valid element that Watir knows how to interact with but in plural form .
def plural?(method)
    value = method.to_s
    plural = value.to_sym
    single = value.sub(/e?s$/, '').to_sym
    !value.match(/s$/).nil? &&
      @elements.include?(plural) &&
      @elements.include?(single)
  end
def plural? ( method ) value = method . to_s plural = value . to_sym single = value . sub ( / e?s$ / , '' ) . to_sym ! value . match ( / s$ / ) . nil? && @elements . include? ( plural ) && @elements . include? ( single ) end
This predicate method checks if a given element is a valid element that
Watir knows how to interact with, but in plural form.
This predicate method checks if a given element is a valid element that Watir knows how to interact with but in plural form .
# Remove the trailing "s" or "es" to de-pluralize.
method
<not_specific>
example
Testable.recognizes?(:spans) # => true Testable.recognizes?(:divs) # => true Testable.recognizes?(:class) # => false Testable.recognizes?(:classes) # => false
Testable . recognizes? ( : spans ) # = > true Testable . recognizes? ( : divs ) # = > true Testable . recognizes? ( : class ) # = > false Testable . recognizes? ( : classes ) # = > false