class SitePrism::Section
Attributes
parent[R]
root_element[R]
Public Class Methods
default_search_arguments()
click to toggle source
# File lib/site_prism/section.rb, line 17 def default_search_arguments return @default_search_arguments if @default_search_arguments superclass.respond_to?(:default_search_arguments) && superclass.default_search_arguments end
new(parent, root_element, &block)
click to toggle source
# File lib/site_prism/section.rb, line 34 def initialize(parent, root_element, &block) @parent = parent @root_element = root_element within(&block) if block end
set_default_search_arguments(*args)
click to toggle source
# File lib/site_prism/section.rb, line 13 def set_default_search_arguments(*args) @default_search_arguments = args end
Private Class Methods
root_element_methods()
click to toggle source
# File lib/site_prism/section.rb, line 25 def root_element_methods ::Capybara::Session::NODE_METHODS + %i[native visible?] end
session_methods()
click to toggle source
# File lib/site_prism/section.rb, line 29 def session_methods ::Capybara::Session::DSL_METHODS - root_element_methods end
Public Instance Methods
capybara_session()
click to toggle source
# File lib/site_prism/section.rb, line 74 def capybara_session Capybara.current_session end
page()
click to toggle source
This was the old API-style of delegating through the Capybara.page call and over-loading the method so we always went through our correct `root_element`
# File lib/site_prism/section.rb, line 66 def page SitePrism::Deprecator.deprecate('Using page inside section') return root_element if root_element SitePrism.logger.warn('Root Element not found; Falling back to Capybara.current_session') capybara_session end
parent_page()
click to toggle source
# File lib/site_prism/section.rb, line 78 def parent_page candidate = parent candidate = candidate.parent until candidate.is_a?(SitePrism::Page) candidate end
to_capybara_node()
click to toggle source
This scopes our calls inside Section
correctly to the `Capybara::Node::Element`
# File lib/site_prism/section.rb, line 54 def to_capybara_node root_element end
within() { |self| ... }
click to toggle source
This allows us to return anything thats passed in as a block to the section at creation time, so that an anonymous section or such-like will have the extra methods
# File lib/site_prism/section.rb, line 60 def within Capybara.within(root_element) { yield(self) } end