only
$21.99

Test Driving Rails

Test drive your Rails applications with this Minitest and fixtures guide.

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."

Steven R. Baker
the author of minitest/mock and RSpec

"An excellent resource for anyone aiming to master the default Rails testing framework – Minitest and fixtures."

Juraj Kostolanský
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."

Patrick Barattin
a Rails developer

Chapters

Includes foreword by Steven R. Baker
the author of minitest/mock and RSpec
1. Introduction

Getting started.

2. Minitest

Introduction to Minitest

3. Doubles

Mocks, Stubs, Mocha, constants.

4. Testing Rails

The Rails test layout.

5. Fixtures

Building test data with fixtures.

6. Model tests

Testing models and business logic.

7. Integration tests

Testing controllers and flows.

8. System tests

Testing with browsers.

9. CI

Continuous integration.

10. Reference

A handy reference.

11. Fin

What did we learn.

Model tests

Model tests should test your models and business logic. This means Active Model, Active Record, or any other Ruby object usually found in app/models. These tests are straightforward to write and fast to execute, so they should be the backbone of your test suite.
Callbacks
Concerns
Attachments
Queues and Jobs
Action Cable
Emails
Service layer
Time
HTTP services

Controller tests

Rails applications are first and foremost web applications handling client HTTP requests. We test responses to these requests with integration and controller tests, both based on ActionDispatch::IntegrationTest.
Actions
Responses
Cookies
Pagination
Attachments
Translations

System tests

System tests, which are usually known as end-to-end tests outside of Rails, are designed to test the entire application from the user's perspective. These tests simulate real user interactions by running a real or headless web browser.
Actions
Finders
Matchers
Sessions
Timeouts
Screenshots

Check out the preview

Buy a copy

Just $21.99 + local tax for PDF, ePUB, and lifetime updates

FAQ

Which versions of Rails are covered?

The 1st edition of the book targets Rails 8, 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.

What about 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.

Buy now

Just $21.99 + local tax for PDF, ePUB, and lifetime updates

Author

Hello, I am Josef Strzibny, a freelance Rails consultant previously working for companies like Red Hat and Phrase. I always had a soft spot for the default Rails testing stack and now I can take you for this joyful ride with me. Testing should be fun.