Module: Watirsome
- Defined in:
- lib/watirsome.rb,
lib/watirsome/errors.rb,
lib/watirsome/version.rb,
lib/watirsome/accessors.rb,
lib/watirsome/initializers.rb
Defined Under Namespace
Modules: Accessors, Errors, Initializers
Constant Summary collapse
- VERSION =
'0.1.6'
Class Attribute Summary collapse
-
.clickable ⇒ Array<Symbol>
Returns array of clickable elements.
-
.readable ⇒ Array<Symbol>
Returns array of readable elements.
-
.selectable ⇒ Array<Symbol>
Returns array of selectable elements.
-
.settable ⇒ Array<Symbol>
Returns array of settable elements.
Class Method Summary collapse
-
.clickable?(tag) ⇒ Boolean
Returns true if tag can have click accessor.
- .included(kls) ⇒ Object
-
.plural?(method) ⇒ Boolean
private
Returns true if method is element accessor in plural form.
-
.pluralize(method) ⇒ Symbol
private
Pluralizes element.
-
.readable?(tag) ⇒ Boolean
Returns true if tag can have text accessor.
-
.selectable?(tag) ⇒ Boolean
Returns true if tag can have select accessor.
-
.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 Attribute Details
.clickable ⇒ Array<Symbol>
Returns array of clickable elements.
8 9 10 |
# File 'lib/watirsome.rb', line 8 def clickable @clickable end |
.readable ⇒ Array<Symbol>
Returns array of readable elements.
5 6 7 |
# File 'lib/watirsome.rb', line 5 def readable @readable end |
.selectable ⇒ Array<Symbol>
Returns array of selectable elements.
14 15 16 |
# File 'lib/watirsome.rb', line 14 def selectable @selectable end |
.settable ⇒ Array<Symbol>
Returns array of settable elements.
11 12 13 |
# File 'lib/watirsome.rb', line 11 def settable @settable end |
Class Method Details
.clickable?(tag) ⇒ Boolean
Returns true if tag can have click accessor.
54 55 56 |
# File 'lib/watirsome.rb', line 54 def clickable?(tag) clickable.include? tag.to_sym end |
.included(kls) ⇒ Object
158 159 160 161 162 |
# File 'lib/watirsome.rb', line 158 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.
122 123 124 125 126 127 128 |
# File 'lib/watirsome.rb', line 122 def plural?(method) str = method.to_s plr = str.to_sym sgl = str.sub(/e?s$/, '').to_sym /s$/ === str && 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.
141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/watirsome.rb', line 141 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?(tag) ⇒ Boolean
Returns true if tag can have text accessor.
84 85 86 |
# File 'lib/watirsome.rb', line 84 def readable?(tag) readable.include? tag.to_sym end |
.selectable?(tag) ⇒ Boolean
Returns true if tag can have select accessor.
74 75 76 |
# File 'lib/watirsome.rb', line 74 def selectable?(tag) selectable.include? tag.to_sym end |
.settable?(tag) ⇒ Boolean
Returns true if tag can have set accessor.
64 65 66 |
# File 'lib/watirsome.rb', line 64 def settable?(tag) settable.include? tag.to_sym end |
.watir_methods ⇒ Array<Sybmol>
Returns array of Watir element methods.
92 93 94 95 96 97 98 99 |
# File 'lib/watirsome.rb', line 92 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.
107 108 109 |
# File 'lib/watirsome.rb', line 107 def watirsome?(method) Watirsome.watir_methods.include? method.to_sym end |