Skip to content

Instantly share code, notes, and snippets.

@masaki
Forked from cfcosta/gist:1149139
Created September 11, 2012 14:17
Show Gist options
  • Save masaki/3698917 to your computer and use it in GitHub Desktop.
Save masaki/3698917 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.strip }
end
end[0].reject(&:empty?)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment