Rails 5 Test Prescriptions
Build a Healthy Codebase
by Noel Rappin
Version: P1.0 (February 2018)
Copyright 2018 The Pragmatic Programmers, LLC. This book is licensed to the individual who purchased it. We don't copy-protect it because that would limit your ability to use it for your own purposes. Please don't break this trustyou can use this across all of your devices but please do not share this copy with other members of your team, with friends, or via file sharing services. Thanks.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein.
About the Pragmatic Bookshelf
The Pragmatic Bookshelf is an agile publishing company. Were here because we want to improve the lives of developers. We do this by creating timely, practical titles, written by programmers for programmers.
Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://pragprog.com.
Our ebooks do not contain any Digital Restrictions Management, and have always been DRM-free. We pioneered the beta book concept, where you can purchase and read a book while its still being written, and provide feedback to the author to help make a better book for everyone. Free resources for all purchasers include source code downloads (if applicable), errata and discussion forums, all available on the book's home page at pragprog.com. Were here to make your life easier.
New Book Announcements
Want to keep up on our latest titles and announcements, and occasional special offers? Just create an account on pragprog.com (an email address and a password is all it takes) and select the checkbox to receive newsletters. You can also follow us on twitter as @pragprog.
About Ebook Formats
If you buy directly from pragprog.com, you get ebooks in all available formats for one price. You can synch your ebooks amongst all your devices (including iPhone/iPad, Android, laptops, etc.) via Dropbox. You get free updates for the life of the edition. And, of course, you can always come back and re-download your books when needed. Ebooks bought from the Amazon Kindle store are subject to Amazon's polices. Limitations in Amazon's file format may cause ebooks to display differently on different devices. For more information, please see our FAQ at pragprog.com/frequently-asked-questions/ebooks. To learn more about this book and access the free resources, go to https://pragprog.com/book/nrtest3, the book's homepage.
Thanks for your continued support,
Andy Hunt
The Pragmatic Programmers
The team that produced this book includes: Andy Hunt (Publisher) Janet Furlow (VP of Operations) Brian MacDonald (Managing Editor) Jacquelyn Carter (Supervising Editor) Katharine Dvorak (Development Editor) Candace Cunningham (Copy Editor) Potomac Indexing, LLC (Indexing) Gilson Graphics (Layout)
For customer support, please contact .
For international rights, please contact .
Table of Contents
Copyright 2018, The Pragmatic Bookshelf.
Early praise for Rails 5 Test Prescriptions: Build a Healthy Codebase
This is my favorite Rails testing book! I love the prescriptions. Its like collecting big thoughts and organizing little ideas within them.
Maricris S. Nonato |
Senior Ruby on Rails Developer, Premiere Speakers Bureau |
I found Noel Rappins Rails 4 Test Prescriptions so helpful, and I was pleased to see Noels humor and thorough explanations continue in this edition. Every time I thought, What about such-and-such? it was covered within a paragraph or two. Best of all, this edition does more than update the previous editionthere is a substantial amount of new material. Im planning to read it again and reference it often!
Tara Scherner de la Fuente |
Software Developer, Allovue |
If youre new to Rails, or new to the idea of testing within Rails, this thorough book will definitely set you on the right path.
Sean Miller |
Solution Developer and Consultant |
Sometimes testing sucks. This book magically makes testing not suck; it makes it easy and rewarding with well-written explanations. It is the essential resource for any developer testing Rails applications. Its more than just a testing primer; developers will learn how to create optimal and efficient test suites for Rails. A must-read for beginners and seasoned programmers alike.
Liz Abinante |
Senior Software Engineer, GitHub |
Noel is an exceptional teacher and it shows! This book is a balanced and pragmatic introduction to testing your Rails applications. It effectively communicates the benefits of various approaches while providing sufficient context on situations where the approach might be less applicable.
Ashish Dixit |
Software Engineer |
Acknowledgments
Its been nine years since I first started working on a book called Rails Test Prescriptions. In that time, many people have helped me make this book better than I could have made it on my own. This includes but is by no means limited to the following people.
Without the encouragement of Brian Hogan and Gregg Pollack, this might still be a self-published book.
Katharine Dvorak has been my editor on this version of the project and has shaped the material this time around. Ive worked with Susannah Pfalzer on all my Pragmatic projects, and shes always been helpful and great to work with.
Many technical people reviewed this version of the book and had their commentsincorporated. They include Sean Boyle, Mike Coutermarsh, Ashish Dixit, M. Scott Ford, Derek Graham, Luis Cabezas Granado, Josh Justice, Kaan Karaca, Nigel Lowry, Sean Miller, Maricris Nonato, Tara Scherner de la Fuente, and Charley Stran.
Ive been very fortunate to be working at Table XI while writing this book. Not only have they been very supportive of the project, but Ive also had the chance to get insights and corrections from my very skilled coworkers.
This book is a commercial product built on the time and generosity of developers who create amazing tools and release them to the world for free. Thanks to all of you. In particular, the maintainers of several of the tools discussed were generous in answering my questions, particularly Eileen Uchitelle from the Rails core team, and Sam Phippen from the RSpec core team.
My family has always been encouraging. Thanks to my children, Emma and Elliot, who are more amazing and awesome than I ever could have hoped. And thanks to my wife Erin, the best part of my life and my favorite person. I love you very much.