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.
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 hereWhen execution stops, you can inspect variables, step through code, and even evaluate arbitrary Ruby expressions.
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.
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.
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.
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.
Rails.logger.debug to print structured output.just logs -f (or rails logs -f).just dev or prune Docker caches.
Create virtual credit / debit cards to keep your real info safe.
Get $5 when you sign up — free to start!
Everything you need to grow your business with confidence!
CRM, Lead Generation, Project Management, Contracts, Online Payments, and more!
The ads above are affiliate links to products I regularly use and highly
recommend.
I may receive a commission if you decide to purchase.