Class: AePageObjects::DocumentQuery::Condition

Inherits:
Object
  • Object
show all
Defined in:
lib/ae_page_objects/document_query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document_class, document_conditions = {}, &block_condition) ⇒ Condition

Returns a new instance of Condition.



6
7
8
9
10
11
# File 'lib/ae_page_objects/document_query.rb', line 6

def initialize(document_class, document_conditions = {}, &block_condition)
  @document_class    = document_class

  @document_conditions = document_conditions || {}
  @document_conditions[:block] = block_condition if block_condition
end

Instance Attribute Details

#document_classObject (readonly)

Returns the value of attribute document_class.



4
5
6
# File 'lib/ae_page_objects/document_query.rb', line 4

def document_class
  @document_class
end

#document_conditionsObject (readonly)

Returns the value of attribute document_conditions.



4
5
6
# File 'lib/ae_page_objects/document_query.rb', line 4

def document_conditions
  @document_conditions
end

Instance Method Details

#match?(document) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ae_page_objects/document_query.rb', line 13

def match?(document)
  @document_conditions.each do |type, value|
    case type
    when :title then
      return false unless Capybara.current_session.driver.browser.title.include?(value)
    when :url then
      return false unless document.current_url.include?(value)
    when :block then
      return false unless value.call(document)
    end
  end

  true
end