module Capybara::ActiveAdmin::Finders::Table

Finders for table_for, it's rows and cells.

Public Instance Methods

find_table_cell(column) click to toggle source
# File lib/capybara/active_admin/finders/table.rb, line 43
def find_table_cell(column)
  selector = table_cell_selector(column)
  find(selector)
end
find_table_row(id: nil, index: nil) click to toggle source
# File lib/capybara/active_admin/finders/table.rb, line 24
def find_table_row(id: nil, index: nil)
  raise ArgumentError, "can't use both :id and :index" if id && index
  raise ArgumentError, 'must provide :id or :index' if id.nil? && index.nil?

  if id
    selector = table_row_selector(id)
    return find(selector)
  end

  selector = table_row_selector(nil)
  find_all(selector, minimum: index + 1)[index]
end
within_table_cell(name) { || ... } click to toggle source

@yield within table>tbody>tr>td

# File lib/capybara/active_admin/finders/table.rb, line 38
def within_table_cell(name)
  cell = find_table_cell(name)
  within(cell) { yield }
end
within_table_for(resource_name = nil) { || ... } click to toggle source

@param resource_name [String, nil] resource name of index page. @yield within table

# File lib/capybara/active_admin/finders/table.rb, line 10
def within_table_for(resource_name = nil)
  selector = table_selector(resource_name)

  within(selector) { yield }
end
within_table_row(id: nil, index: nil) { || ... } click to toggle source

id [String, Integer, nil] record ID. index [Integer] row index in table (starts with 0). @yield within table>tbody>tr

# File lib/capybara/active_admin/finders/table.rb, line 19
def within_table_row(id: nil, index: nil)
  row = find_table_row(id: id, index: index)
  within(row) { yield }
end