Skip to content

Instantly share code, notes, and snippets.

@nickcharlton
Last active May 28, 2021 16:49
Show Gist options
  • Save nickcharlton/531e16038f43d7094091938ba69029b6 to your computer and use it in GitHub Desktop.
Save nickcharlton/531e16038f43d7094091938ba69029b6 to your computer and use it in GitHub Desktop.
Gist from Drafts

Debugging capybara-table

Bumping Nokogiri to 1.11.5, caused our tests around HTML tables to start failing with ERROR: Recursion limit exceeded. The change that caused this is in commit #9fcb7d (see also: the full set of changes), where the recursion limit is restricted to 500 (see: libxml2 commit), which is how it started happening with this Nokogiri update.

In investigating what was causing this to recur, it seems like we don't need all of capybara-table, as enough is already included in Capybara itself.

I did consider just dropping the dependency, but the Matcher/Renderer classes are key to the usability of our tests — I even tried not using them but trying to factor out the dependency was a horrible experience.

My next step would be to try and switch the Capybara selector that CapybaraTable::RspecMatchers uses to the ones already in Capybara: table.rb and table_row.rb. This might be as simple as vendering the RspecMatchers.rb file into the project and seeing what happens. Looking at the history around the matchers, there's some joint history but later on they seem to have been refactored (hence, Capybara doesn't have the issue we're seeing by Capybara Table does).

A word to the wise: I got lost a bit of time in trying to get capybara-table running locally. Don't. Just use Docker as the old version of Ruby it needs (2.3.3) is a nightmare to compile and then you'll need to upgrade it to something like 2.6.6 to get a the right version of Nokogiri anyway.

(If you end up needing to us an old version of Ruby, you can do that with Docker like this: docker run -i -t -P -v "$PWD:/app" ruby:2.3.3 /bin/bash, which will run a 2.3.3 container, mount the current directory at /app and drop you into a shell.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment