The Problem
In the past I’ve always used ruby-debug (or more recently debugger) to set breakpoints and debug my rails integration tests built with Capybara and Selenium. A problem I’ve continually run into is that when the debugger launches it suspends all threads, including both the thread Capybara is running on as well as the rails server thread, so when trying to do something with Capybara that requires a server response it just times out.
Just to verify this behavior of ruby-debug/debugger, you can try:
require ''debugger''
Thread.new { sleep 1; puts "done!" }; debugger
When the debugger launches, if you try something like sleep 2 to pass some time, the separate thread will stay suspended, and it’ll only actually print “done!” once you exit the debugger.
Use a REPL instead
The suspended threads issue can be avoided entirely by using a REPL (read-evaluate-print loop) instead of a breakpoint. Doing this with IRB requires some trickery to get the context right, but with Pry it’s super easy:
Capybara.pry
This allows you to run Capybara methods (visit, fill_in, etc) directly, with other threads running happily so the rails server will respond as needed.