0.03
Low commit activity in last 3 years
No release in over a year
Selectors for working with tables for Capybara
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 10.0
~> 3.0
~> 2.3

Runtime

 Project Readme

CapybaraTable

Some neat Capybara selectors and matchers for working with HTML tables.

Installation

Add this line to your application's Gemfile:

gem 'capybara_table'

And then execute:

$ bundle

Or install it yourself as:

$ gem install capybara_table

If you're using RSpec, require the matchers:

require "capybara_table/rspec"

Otherwise

Usage

If you have a table like this:

<table>
  <caption>People</caption>
  <tr>
    <th>First Name</th>
    <th>Last Name</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Jonas</td>
    <td>Nicklas</td>
    <td>31</td>
  </tr>
  <tr>
    <td colspan="2">John</td>
    <td>22</td>
  </tr>
</table>

Then you can do this

# find a table by caption
find(:table, "People") # by caption

# find a table row by its headers, even works with colspans!
# (note the extra hash at the end)
find(:table_row, {"First Name" => "Jonas", "Last Name" => "Nicklas"}, {})

# Assert on a table row with RSpec
expect(find(:table, "People")).to have_table_row("First Name" => "Jonas", "Last Name" => "Nicklas")

# Assert on a table row with MiniTest
within :table, "People" do
  assert_selector(:table_row, {"First Name" => "Jonas", "Last Name" => "Nicklas"}, {})
end

License

The gem is available as open source under the terms of the MIT License.