Skip to content

Instantly share code, notes, and snippets.

@cfcosta
Created August 16, 2011 13:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cfcosta/1149139 to your computer and use it in GitHub Desktop.
Save cfcosta/1149139 to your computer and use it in GitHub Desktop.
Implementation of Webrat's #table_at for using with Capybara. Not the cleanest implementation ever, but it works correctly.
def table_at(selector)
Nokogiri::HTML(page.body).css(selector).map do |table|
table.css('tr').map do |tr|
tr.css('td').map { |td| td.text }
end
end[0].reject(&:empty?)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment