Class: CapybaraObjects::PageObject
- Inherits:
-
Object
- Object
- CapybaraObjects::PageObject
- Includes:
- ConvenienceMethods, InitializeMethods, LocationMethods, RegistryMethods, ScopedFinders, ValidationMethods
- Defined in:
- lib/capybara_objects/page_object.rb
Overview
A page object
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
-
.ptype(type) ⇒ Object
Registers a “ptype” alias for this class.
-
.url(url) ⇒ Object
Defines the default url.
Instance Method Summary collapse
-
#attach(options = {}) ⇒ ::CapybaraObjects::PageObject
Attaches the page object to the current page.
-
#initialize(options = {}) ⇒ PageObject
constructor
A new instance of PageObject.
-
#visit ⇒ ::CapybaraObjects::PageObject
Visits the pre configured URL to make this page available.
Methods included from ScopedFinders
#get_component, #root_node, #scoped_find
Methods included from ConvenienceMethods
Methods included from ValidationMethods
Constructor Details
#initialize(options = {}) ⇒ PageObject
Returns a new instance of PageObject.
33 34 35 36 |
# File 'lib/capybara_objects/page_object.rb', line 33 def initialize( = {}) super self.url ||= default_url end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
18 19 20 |
# File 'lib/capybara_objects/page_object.rb', line 18 def url @url end |
Class Method Details
.ptype(type) ⇒ Object
Registers a “ptype” alias for this class
22 23 24 |
# File 'lib/capybara_objects/page_object.rb', line 22 def ptype(type) registry.register_ptype type, self end |
.url(url) ⇒ Object
Defines the default url. Can be overriden in the instance
28 29 30 |
# File 'lib/capybara_objects/page_object.rb', line 28 def url(url) self.default_url = url end |
Instance Method Details
#attach(options = {}) ⇒ ::CapybaraObjects::PageObject
Attaches the page object to the current page
50 51 52 53 |
# File 'lib/capybara_objects/page_object.rb', line 50 def attach( = {}) validate! self end |
#visit ⇒ ::CapybaraObjects::PageObject
Visits the pre configured URL to make this page available
41 42 43 44 45 46 |
# File 'lib/capybara_objects/page_object.rb', line 41 def visit raise ::CapybaraObjects::Exceptions::MissingUrl unless url.present? page.visit url validate! self end |