Writing effective tests is a necessary part of Ruby development. An effective test suite guides you towards maintainable code. It allows you to make major changes to your application and be confident that everything still works.
Testing Rails is a practical approach to learning testing. We'll discuss the tools and processes we use every day at thoughtbot, as well as common anti-patterns and solutions to real world problems with plenty of examples.
Is this book for me?
You might have never written a test. Maybe you have written tests in other languages. Or perhaps, you've written some Rails tests, but want to do it better.
In Testing Rails, we will show you how to get started writing tests, from the very basics to the things that trip up even intermediate developers. We'll cover all of the concepts you need to understand to write a successful Rails test suite.
More than just a book
The book is written using Markdown and distributed via GitHub. When you purchase, we give you access directly to the repository, so you can use the GitHub issues features to give us feedback about what we’ve written and what you’d like to see.
This also means that you’ll be the first to know when new content has been added to the book, and have the easiest time getting it.
Table of Contents
- Why test?
- Test Driven Development
- Characteristics of an Effective Test Suite
- Example Application
Types of Tests
- The Testing Pyramid
- Feature Specs
- Model Specs
- Request Specs
- View Specs
- Controller Specs
- Helper Specs
- Mailer Specs
- Testing in isolation (doubles, stubs, spies, and mocks)
- External Services
- Page Objects
- Continuous Integration
- Coverage Reports
- Slow Tests
- Intermittent Failures
- Brittle Tests
- Testing Implementation Details
- Let, Subject, and Before
- Bloated Factories
- Using Factories Like Fixtures
- False Positives
- Stubbing the System Under Test
- Testing Behavior, Not Implementation
- Testing Code You Don't Own
You'll need an account to access this in our app. Please create a password to continue.
Download from the App Store or text yourself a link to the app
You will be added to the GitHub repository with code examples within one business day.