Class: CapybaraPageObject::Node

Inherits:
Object
  • Object
show all
Includes:
Delegators
Defined in:
lib/capybara-page-object/node.rb

Direct Known Subclasses

Element, Page

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Delegators

#all, #find, #text

Constructor Details

#initialize(source = nil) ⇒ Node

Returns a new instance of Node.



10
11
12
# File 'lib/capybara-page-object/node.rb', line 10

def initialize(source=nil)
  @source = source
end

Instance Attribute Details

#sourceObject

Returns the value of attribute source.



8
9
10
# File 'lib/capybara-page-object/node.rb', line 8

def source
  @source
end

Class Method Details

.element(name, &block) ⇒ Object



27
28
29
# File 'lib/capybara-page-object/node.rb', line 27

def self.element(name, &block)
  define_method(name, &block)
end

.field(name, &block) ⇒ Object



31
32
33
# File 'lib/capybara-page-object/node.rb', line 31

def self.field(name, &block)
  define_method(name, &block)
end

.from_string(string, target) ⇒ Object



14
15
16
# File 'lib/capybara-page-object/node.rb', line 14

def self.from_string(string, target)
  new(Capybara.string(string).find(target))
end

Instance Method Details

#classesObject



18
19
20
21
# File 'lib/capybara-page-object/node.rb', line 18

def classes
  classes_list = source[:class] or return []
  classes_list.split(' ')
end