Using Pry to Troubleshoot Test Failures

Failures troubleshooting with Pry

Pry is really a wonderful console, but again, this is Rails Test Prescriptions, not Rails Console Prescriptions. Luckily, we can invoke Pry directly from inside a test.

Pry session

If we add the line binding.pry to our code, then a Pry session will start when the code execution reaches that line.

Let’s see how this works. We’ll put a binding.pry in one of the tests in the action test file creates_project_spec.rb. Can you guess which line from this session trace contains binding.pry?

Get hands-on with 1200+ tech skills courses.