Debugging & Testing

A smooth developer experience starts with great debugging tools and a solid testing foundation. This guide covers the built-in ruby-debug workflow and our recommended testing stack built on RSpec and Playwright.

For richer in-browser error pages and consoles (Web Console & BetterErrors), see the Authentication guide, which sets them up alongside user sign-in.

1. ruby-debug (built-in)

Rails 7+ ships with the debug gem (the successor to byebug). It is already in your Gemfile, so you can drop a breakpoint anywhere in your code:

# Set a breakpoint anywhere in your code
debugger

# Then run your server (or tests) and execution will pause here

When execution stops, you can inspect variables, step through code, and even evaluate arbitrary Ruby expressions.

Debugging in Docker

If you are using the LocoMotion Docker setup, Rails will automatically start a remote debugger.

After adding a debugger breakpoint and refreshing the browser, the request will appear to hang. Open another terminal and run:

just app-debug

This attaches to the remote debugger inside the container so you can step through code just like you would locally.

2. Testing

Before you start creating a bunch of models and controllers, it is worth getting a solid testing foundation in place. Rails ships with MiniTest out of the box, and many people happily stick with it since it is built-in and is essentially just Ruby.

Many larger teams, however, opt for RSpec — a Behavior Driven Development (BDD) framework with a huge ecosystem of plugins. After building many applications, we recommend RSpec paired with factory_bot and Shoulda Matchers.

For end-to-end / UI testing we recommend Playwright over older tools — it closely mimics the real user experience in a browser and lets you watch tests run in real-time, including in-browser debugging. You can even write your E2E specs in Ruby via the playwright-ruby-client.

Playwright Ruby Client

After evaluating the playwright-ruby-client, we do not recommend it due to multiple issues with running tests concurrently and reverting the database after test runs. We recommend using the official Playwright for TypeScript/JavaScript instead.

Why not Cypress?

We used to recommend Cypress for end-to-end tests, but its reliance on JavaScript and occasionally flaky runs led us to adopt Playwright instead.

3. Troubleshooting Tips

  • Use Rails.logger.debug to print structured output.
  • Tail logs with just logs -f (or rails logs -f).
  • If containers misbehave, rebuild with just dev or prune Docker caches.
Made with by Profoundry .
Copyright © 2023-2026 Profoundry LLC.
All rights reserved.