class CapybaraObjects::PageObject

A page object

Attributes

url[RW]

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method CapybaraObjects::LocationMethods::new
# File lib/capybara_objects/page_object.rb, line 33
def initialize(options = {})
  super
  self.url ||= default_url
end
ptype(type) click to toggle source

Registers a “ptype” alias for this class @param [String] type The alias or type to register this class with.

# File lib/capybara_objects/page_object.rb, line 22
def ptype(type)
  registry.register_ptype type, self
end
url(url) click to toggle source

Defines the default url. Can be overriden in the instance @param [String] url The default url

# File lib/capybara_objects/page_object.rb, line 28
def url(url)
  self.default_url = url
end

Public Instance Methods

attach(options = {}) click to toggle source

Attaches the page object to the current page @return [::CapybaraObjects::PageObject] self - allows chaining of methods

# File lib/capybara_objects/page_object.rb, line 50
def attach(options = {})
  validate!
  self
end
visit() click to toggle source

Visits the pre configured URL to make this page available @raise ::CapybaraPageObjects::Exceptions::MissingUrl @return [::CapybaraObjects::PageObject] self - allows chaining of methods

# File lib/capybara_objects/page_object.rb, line 41
def visit
  raise ::CapybaraObjects::Exceptions::MissingUrl unless url.present?
  page.visit url
  validate!
  self
end