Rails Testing for Beginners

Rails Testing for Beginners

When you’re getting started with testing it can be unclear what to test and how.

As you try to write tests, you may find yourself thinking thoughts like this:

  • “I don’t know what to write tests for”
  • “I know I should be testing, I just don’t know how to get started”
  • “It takes me forever to figure out how to write each test”
  • “I wish there was a simple, repeatable process I could use to write tests”
  • “No matter how much I read about testing, I just don’t get it”

If you don’t write tests then you’ll end up dealing with the consequences of not testing:

  • Fragile, buggy code
  • A game of “whack-a-mole” – fix a bug only to introduce a new one somewhere else
  • Nerve-wracking deployments followed by firefighting and maybe even rollbacks
  • A bunch of wasted time and frustration when you do try (and fail) to write tests
  • A feeling of being “behind” as a professional
  • Lost job opportunities when employers want to see testing skills that you don’t have

What would life be like if you had the testing skills you wanted?

In you were a competent Rails tester then:

  • You’d always know what to write tests for
  • You’d write tests for features just as easily as the feature itself
  • You’d know the exact formula to write a test for almost any feature
  • Your base level of understanding testing principles would help you more easily absorb the arcane teachings of testing books and articles

And instead of dealing with the painful consequences of not writing tests, you’d experience the positive results that testing brings:

  • Robust, thoroughly tested code
  • Any regressions are caught automatically by the test suite
  • Confident, uneventful deployments
  • Enhanced productivity and cleaner code
  • The ability to refactor freely and make your code even more maintainable and robust
  • A feeling of being a competent professional
  • Enhanced career opportunities

Introducing: Rails Testing for Beginners

What’s Inside

Rails Testing for Beginners is not an encyclopedia of all the Rails testing tools.
Instead, my aim is to walk you through the of testing “maturity” that I think every developer has to go through in order to become a competent tester.

The book is divided into four parts, one for each phase of testing maturity.

  • Part 1: Just Write Some Tests, Any Tests
    • Choosing a Test Framework
    • Testing with Just Ruby, No Rails
    • Setting Up a Rails App for Testing
    • Writing Some Trivial Rails Tests
  • Part 2: Test the Simple Stuff
    • Understanding Factories and Fixtures
    • Using Factories
    • Putting Feature Specs on Scaffolded CRUD Interfaces
    • Putting Validation Specs on Scaffolded Models
  • Part 3: Test the Complicated Stuff
    • Dealing with Complicated Setup
    • Dealing with External Dependencies
    • Adding Tests to Legacy Code
  • Part 4: Hone Your Skills
    • When to TDD and When Not to TDD
    • How to Keep Tests Readable


How long is the book?

I haven’t written the book yet. For the initial version of the book I’m shooting for a nice and lean 50 pages.

What’s the format of the book?

PDF ebook. No print version yet.

When will the book be ready?

Not sure. My target is the spring of 2019.

What testing frameworks and tools are covered?

Mostly RSpec, just because that’s what’s popular. Capyabara, Factory Bot, Faker and others are discussed as well. What’s more important than the testing framework or other tools though are the testing principles covered that apply no matter what set of tools you’re using.

What versions of Rails/RSpec are covered?

Rails 5.2 and RSpec 3.8.

What if I buy it and I don’t like it? Do I get my money back?

Yes. I offer a 100% no-questions-asked money-back guarantee.

About the Author

Jason Swett is a developer, speaker, trainer, author and host of The Ruby Testing Podcast.

Since putting his first website online in 1996, Jason has worked with organizations like AT&T, Lenovo, VMware, HP, Dow Jones, Deloitte, Kroger and the University of Chicago.

He has taught programming in the United States, The Netherlands, Bulgaria and Nigeria.

Jason lives in Sand Lake, Michigan with his wife and two kids.

Want the Book?

Click the button below and put in your email address to get notified when Rails Testing for Beginners comes out.

Notify Me When the Book is Ready