class SitePrism::AllThere::ExpectedItems

@api private

The Expected Items to be present on a SitePrism Page or Section

Attributes

instance[R]

Public Class Methods

new(instance) click to toggle source
# File lib/site_prism/all_there/expected_items.rb, line 13
def initialize(instance)
  @instance = instance
end

Public Instance Methods

array() click to toggle source

@return [Array<Array<Symbol>>] All expected mapped items

# File lib/site_prism/all_there/expected_items.rb, line 19
def array
  [
    element,
    elements,
    section,
    sections,
    iframe,
  ]
end
element() click to toggle source

@return [Array<Symbol>] All expected items that were mapped as element

# File lib/site_prism/all_there/expected_items.rb, line 31
def element
  mapped_checklist_of(:element) || []
end
elements() click to toggle source

@return [Array<Symbol>] All expected items that were mapped as elements

# File lib/site_prism/all_there/expected_items.rb, line 37
def elements
  mapped_checklist_of(:elements) || []
end
iframe() click to toggle source

@return [Array<Symbol>] All expected items that were mapped as iframe

# File lib/site_prism/all_there/expected_items.rb, line 55
def iframe
  mapped_checklist_of(:iframe) || []
end
section() click to toggle source

@return [Array<Symbol>] All expected items that were mapped as section

# File lib/site_prism/all_there/expected_items.rb, line 43
def section
  mapped_checklist_of(:section) || []
end
sections() click to toggle source

@return [Array<Symbol>] All expected items that were mapped as sections

# File lib/site_prism/all_there/expected_items.rb, line 49
def sections
  mapped_checklist_of(:sections) || []
end

Private Instance Methods

checklist() click to toggle source
# File lib/site_prism/all_there/expected_items.rb, line 74
def checklist
  instance.class.expected_items
end
mapped_checklist() click to toggle source
# File lib/site_prism/all_there/expected_items.rb, line 65
def mapped_checklist
  if checklist
    SitePrism.logger.debug('Expected Items has been set.')
    mapped_items.array.select { |name| checklist.include?(name) }
  else
    mapped_items.array
  end
end
mapped_checklist_of(type) click to toggle source
# File lib/site_prism/all_there/expected_items.rb, line 61
def mapped_checklist_of(type)
  mapped_items.hash[type]&.select { |name| mapped_checklist.include?(name) }
end
mapped_items() click to toggle source
# File lib/site_prism/all_there/expected_items.rb, line 78
def mapped_items
  @mapped_items ||= MappedItems.new(instance)
end