Module: Watirsome
- Defined in:
- lib/watirsome.rb,
lib/watirsome/errors.rb,
lib/watirsome/version.rb,
lib/watirsome/accessors.rb,
lib/watirsome/initializers.rb
Overview
General module which holds all appropriate Watirsome API. Includers can use accessors and initializers API.
Defined Under Namespace
Modules: Accessors, Initializers
Constant Summary collapse
- CannotPluralizeError =
Class.new(StandardError)
- VERSION =
'0.2.2'.freeze
Class Method Summary collapse
-
.clickable ⇒ Array<Symbol>
Returns array of clickable elements.
-
.clickable?(tag) ⇒ Boolean
Returns true if tag can have click accessor.
-
.included(kls) ⇒ Object
self.
-
.plural?(method) ⇒ Boolean
private
Returns true if method is element accessor in plural form.
-
.pluralize(method) ⇒ Symbol
private
Pluralizes element.
-
.readable ⇒ Array<Symbol>
Returns array of readable elements.
-
.readable?(tag) ⇒ Boolean
Returns true if tag can have text accessor.
-
.settable ⇒ Array<Symbol>
Returns array of settable elements.
-
.settable?(tag) ⇒ Boolean
Returns true if tag can have set accessor.
-
.watir_methods ⇒ Array<Sybmol>
Returns array of Watir element methods.
-
.watirsome?(method) ⇒ Boolean
Return true if method can be proxied to Watir, false otherwise.
Class Method Details
.clickable ⇒ Array<Symbol>
Returns array of clickable elements.
86 87 88 |
# File 'lib/watirsome.rb', line 86 def clickable @clickable ||= i[a link ] end |
.clickable?(tag) ⇒ Boolean
Returns true if tag can have click accessor.
108 109 110 |
# File 'lib/watirsome.rb', line 108 def clickable?(tag) clickable.include? tag.to_sym end |
.included(kls) ⇒ Object
self
214 215 216 217 218 |
# File 'lib/watirsome.rb', line 214 def self.included(kls) kls.extend Watirsome::Accessors::ClassMethods kls.__send__ :include, Watirsome::Accessors::InstanceMethods kls.__send__ :include, Watirsome::Initializers end |
.plural?(method) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns true if method is element accessor in plural form.
178 179 180 181 182 183 184 185 186 |
# File 'lib/watirsome.rb', line 178 def plural?(method) str = method.to_s plr = str.to_sym sgl = str.sub(/e?s$/, '').to_sym !str.match(/s$/).nil? && Watirsome.watir_methods.include?(plr) && Watirsome.watir_methods.include?(sgl) end |
.pluralize(method) ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Pluralizes element.
199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/watirsome.rb', line 199 def pluralize(method) str = method.to_s # first try to pluralize with "s" if Watirsome.watir_methods.include?(:"#{str}s") :"#{str}s" # now try to pluralize with "es" elsif Watirsome.watir_methods.include?(:"#{str}es") :"#{str}es" else # looks like we can't pluralize it raise Errors::CannotPluralizeError, "Can't find plural form for #{str}!" end end |
.readable ⇒ Array<Symbol>
Returns array of readable elements.
78 79 80 |
# File 'lib/watirsome.rb', line 78 def readable @readable ||= i[div span p h1 h2 h3 h4 h5 h6 select_list text_field textarea checkbox radio] end |
.readable?(tag) ⇒ Boolean
Returns true if tag can have text accessor.
136 137 138 |
# File 'lib/watirsome.rb', line 136 def readable?(tag) readable.include? tag.to_sym end |
.settable ⇒ Array<Symbol>
Returns array of settable elements.
94 95 96 |
# File 'lib/watirsome.rb', line 94 def settable @settable ||= i[text_field file_field textarea checkbox select_list] end |
.settable?(tag) ⇒ Boolean
Returns true if tag can have set accessor.
122 123 124 |
# File 'lib/watirsome.rb', line 122 def settable?(tag) settable.include? tag.to_sym end |
.watir_methods ⇒ Array<Sybmol>
Returns array of Watir element methods.
144 145 146 147 148 149 150 151 |
# File 'lib/watirsome.rb', line 144 def watir_methods unless @watir_methods @watir_methods = Watir::Container.instance_methods @watir_methods.delete(:extract_selector) end @watir_methods end |
.watirsome?(method) ⇒ Boolean
Return true if method can be proxied to Watir, false otherwise.
163 164 165 |
# File 'lib/watirsome.rb', line 163 def watirsome?(method) Watirsome.watir_methods.include? method.to_sym end |