Test Driving Rails
Just updated for Rails 8.1 and Minitest 6
Learn how to test your Rails applications with Minitest and fixtures.
Learn about Minitest test cases, assertions, mocks and stubs.
Design simple to use test data with fixtures.
Write fast Rails models, controllers and system tests.
NEW Optimize test databases for optimal performance.
NEW Use bundled Claude Skills for writing tests with AI.
Testimonials
"Test Driving Rails is a concise yet incredibly complete guide to the patterns and tools we use to effectively test our Ruby on Rails applications, ensuring that our software does exactly what we said it would, every time we make a change."
the author of minitest/mock and RSpec
"The book does a great job of showing how far you can get by simply using what Rails already gives you. It’s practical, focused, and free of unnecessary ceremony."
the author of RubyLLM
"It's the perfect book to get you up to speed using the default testing framework for Rails, perfectly complementing the official guides. Short & sweet."
a Ruby developer
"An excellent resource for anyone aiming to master the default Rails testing framework – Minitest and fixtures."
a full-stack Rails developer
"I started a new project with factories, but thanks to this book I made my tests 32% faster with fixtures."
a Rails developer
Chapters
the author of minitest/mock and RSpec
Getting started.
Introduction to Minitest
Mocks, Stubs, Mocha, constants.
The Rails test layout.
Building test data with fixtures.
Testing models and business logic.
Testing controllers and flows.
Testing with browsers.
Continuous integration.
Optimize SQLite, MySQL, and PostgreSQL.
A handy reference.
What did we learn.
Model tests
Controller tests
System tests
Databases
Check out the preview
FREE bonus
Claude skills
Join the agentic revolution by incorporating premade Claude Skills for Claude Code to set up and write your tests. You can use the setup to optimize your current state.
setup-tests
write-test
FAQ
Which versions of Rails are covered?
The first update of the 1st edition targets Rails 8.1 and Minitest 6, but also works well for previous versions.
Who is the book for?
The book is designed for Rails beginners and professionals alike, but basic knowledge of Rails is assumed. Previous experience with Minitest or fixtures is not required.
Is Minitest worth it if I use RSpec?
Minitest is seemlesly integrated with Rails from the get-go. You don't need to update your gemfile or think about specific features when they come out.
Fixtures instead of factories?
This book talks exclusively about building test data with Rails fixtures. They are fast and reusable datasets for different tasks across development, test, and production.
What about updates?
This book comes with free lifetime updates if you buy this first edition. Last update happened on 16. 2. 2026.
Writing
Check out some of my Minitest posts:
- Lessons learned from studying Fizzy test suite
- Testing time in Rails with Minitest
- Validating fixtures before running the test suite
Author

