Method: Testable.pluralize
- Defined in:
- lib/testable/element.rb
.pluralize(method) ⇒ Object
This method will allow a particular element name to be pluralized.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/testable/element.rb', line 53 def self.pluralize(method) value = method.to_s # This bit is not what you would call optimized. Essentially, it just # tries to ppluralize with "s" and see if that method is included in the # Watir methods. If that fails, then an attempt to pluralize with "es" is # tried. If that fails, the assumption is made that a pluralized form of # the Watir method does not exist. if @elements.include?(:"#{value}s") :"#{value}s" elsif @elements.include?(:"#{value}es") :"#{value}es" else raise Testable::Errors::PluralizedElementError, "Unable to find plural form for #{value}!" end end |