Class: CapybaraPageObject::Base

Inherits:
Object
  • Object
show all
Includes:
Extractors::Common, Extractors::PageLevel
Defined in:
lib/base.rb

Direct Known Subclasses

Image, Page, Table

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Extractors::PageLevel

#forms, #meta_description, #meta_keywords, #tables, #title

Methods included from Extractors::Common

#all, #data, #extract, #find

Constructor Details

#initialize(source = nil) ⇒ Base

Returns a new instance of Base.



8
9
10
11
# File 'lib/base.rb', line 8

def initialize(source=nil)
  source ||= Capybara.current_session
  @source = source
end

Instance Attribute Details

#sourceObject

Returns the value of attribute source.



6
7
8
# File 'lib/base.rb', line 6

def source
  @source
end

Instance Method Details

#path(*args) ⇒ Object

Raises:

  • (PageObjectMissingPath)


13
14
15
# File 'lib/base.rb', line 13

def path(*args)
  raise PageObjectMissingPath, "You need to override this"
end

#prefixObject



17
18
19
# File 'lib/base.rb', line 17

def prefix
  ''
end

#visitObject



21
22
23
24
# File 'lib/base.rb', line 21

def visit
  source.visit prefix + path
  self
end