Class: PageMagic::Element::Query
- Inherits:
-
Object
- Object
- PageMagic::Element::Query
- Defined in:
- lib/page_magic/element/query.rb
Overview
class Query - models overall queries for Capybara, queries can include:
- requirements on element type
- selection criteria, modeled through the Selector class
- options
Constant Summary collapse
- ELEMENT =
Query.new
- TEXT_FIELD =
CHECKBOX = SELECT_LIST = RADIOS = TEXTAREA = Query.new(:field)
- LINK =
Query.new(:link)
- BUTTON =
Query.new(:button)
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.find(type) ⇒ Query
Find a query using it's name.
Instance Method Summary collapse
-
#build(locator, options = {}) ⇒ Array
Build query parameters for Capybara's find method.
-
#initialize(type = nil) ⇒ Query
constructor
A new instance of Query.
Constructor Details
#initialize(type = nil) ⇒ Query
Returns a new instance of Query.
23 24 25 |
# File 'lib/page_magic/element/query.rb', line 23 def initialize(type = nil) @type = type end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
20 21 22 |
# File 'lib/page_magic/element/query.rb', line 20 def type @type end |
Class Method Details
Instance Method Details
#build(locator, options = {}) ⇒ Array
Build query parameters for Capybara's find method
31 32 33 34 35 36 37 |
# File 'lib/page_magic/element/query.rb', line 31 def build(locator, = {}) [].tap do |array| selector = Selector.find(locator.keys.first) array << selector.build(type, locator.values.first) array << unless .empty? end.flatten end |