Testing Rails

$0+
4 ratings

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.

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.

Read a sample chapter.

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 , 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

Introduction

  • Why test?
  • Test Driven Development
  • Characteristics of an Effective Test Suite
  • Example Application
  • RSpec

Types of Tests

  • The Testing Pyramid
  • Feature Specs
  • Model Specs
  • Request Specs
  • View Specs
  • Controller Specs
  • Helper Specs
  • Mailer Specs

Intermediate Testing

  • Testing in isolation (doubles, stubs, spies, and mocks)
  • External Services
  • Page Objects
  • JavaScript
  • Continuous Integration
  • Coverage Reports

Antipatterns

  • Slow Tests
  • Intermittent Failures
  • Brittle Tests
  • Duplication
  • 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


Testing Rails is written by Josh Steiner and Joël Quenneville.

$
I want this!

You'll get access to GitHub, including eBook versions of the book, updates, and the ability to interact with the author.

Copy product URL

Ratings

5.0
(4 ratings)
5 stars
100%
4 stars
0%
3 stars
0%
2 stars
0%
1 star
0%
$0+

Testing Rails

4 ratings
I want this!