Class: Wrapybara::TableBody

Inherits:
Object
  • Object
show all
Includes:
Element
Defined in:
lib/wrapybara/elements/table_body.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Element

#click, #default_how, #default_scope, #disabled?, #element_identifier, #enabled?, #focused?, #get_element, #parent_identifier, #path, #should_be_disabled, #should_be_enabled, #should_be_focused, #should_be_visible, #should_have_attribute, #should_not_be_disabled, #should_not_be_enabled, #should_not_be_focused, #should_not_be_visible, #should_not_have_attribute, #style, #visible?, #within

Constructor Details

#initialize(table) ⇒ TableBody

Returns a new instance of TableBody.



7
8
9
10
# File 'lib/wrapybara/elements/table_body.rb', line 7

def initialize(table)
  @parent = table
  @element = table.element.find('tbody') rescue nil
end

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



5
6
7
# File 'lib/wrapybara/elements/table_body.rb', line 5

def element
  @element
end

#parentObject (readonly)

Returns the value of attribute parent.



5
6
7
# File 'lib/wrapybara/elements/table_body.rb', line 5

def parent
  @parent
end

Instance Method Details

#cell(*args) ⇒ Object



20
21
22
# File 'lib/wrapybara/elements/table_body.rb', line 20

def cell(*args)
  TableCell.new(self, args)
end

#exists?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/wrapybara/elements/table_body.rb', line 36

def exists?
  !@element.nil?
end

#should_existObject



12
13
14
# File 'lib/wrapybara/elements/table_body.rb', line 12

def should_exist
  super "Expected table #{@parent.how} '#{self.parent_identifier} to have a body"
end

#should_have_cells(labels) ⇒ Object



24
25
26
27
28
# File 'lib/wrapybara/elements/table_body.rb', line 24

def should_have_cells(labels)
  labels.each do |label|
    self.cell(label).should_exist
  end
end

#should_not_existObject



16
17
18
# File 'lib/wrapybara/elements/table_body.rb', line 16

def should_not_exist
  super "Did not expect table #{@parent.how} '#{self.parent_identifier} to have a body"
end

#should_not_have_cells(labels) ⇒ Object



30
31
32
33
34
# File 'lib/wrapybara/elements/table_body.rb', line 30

def should_not_have_cells(labels)
  labels.each do |label|
    self.cell(label).should_not_exist
  end
end