A beginner-friendly Rails model spec tutorial

by Jason Swett,

What this is

Using you’re using RSpec to write Rails tests, there are several different types of tests you can write. There are system specs, request specs, view specs, model specs, and a number of others.

Among all these types of tests, I consider model specs to be perhaps the most important. Models are where I put the “meat” of my application’s code. Since model code is my most important code, model specs are my most important specs.

If haven’t done much model testing before and you aren’t sure how to come at it, this tutorial will show you how to take an idea for a feature and translate it into model specs.

Who this is for

This is a very beginner-level tutorial, intended for developers with very little model testing experience.

If you’ve never done any testing at all before, I would first recommend my Rails testing “hello world” tutorial and my Getting Started with Rails Testing articles.

But if you have a little bit of familiarity with RSpec and want to understand how to get started with testing models, let’s get started with Part One of this two-part tutorial.

Continue to Part One

Leave a Reply

Your email address will not be published. Required fields are marked *