Method: SitePrism::Loadable::ClassMethods#load_validation

Defined in:
lib/site_prism/loadable.rb

#load_validation(&block) ⇒ Proc

Appends a load validation block to the page/section class.

When ‘loaded?` is called, these blocks are instance_eval’d against the current page instance. This allows users to wait for specific events to occur on the page or certain elements to be loaded before performing any actions on the page.

This block can contain up to 2 elements in an array -> The first is the physical validation test to be truthily evaluated.

If this does not pass, then the 2nd item (if defined), is output as an error message on the FailedLoadValidationError

Parameters:

  • block (&block)

    A block which returns true if the page loaded successfully, or false if it did not.

Returns:

  • (Proc)


95
96
97
# File 'lib/site_prism/loadable.rb', line 95

def load_validation(&block)
  _load_validations << block
end