From the course: Ruby: Testing with RSpec

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Model specs

Model specs - Ruby Tutorial

From the course: Ruby: Testing with RSpec

Start my 1-month free trial

Model specs

- In this movie, we're gonna talk about how to write specs for your models. I think that the model specs are the most important specs that you can have in your application. If you have no test coverage, that's where I'd start. Start by spec'ing your models. The models are easy to work with, mostly because unlike controllers, there's no request response cycle to worry about. You don't have to worry about rendering templates, or anything like that. We just have an object. And we can create an instance in that object, and then we can poke and prod at it to see if we get the results that we want. As a beginner, they're gonna be the easiest to take on, and I think they're gonna add the most value. While for the most part it's gonna be straight forward, there are a few pointers that I can offer to help you get past some of the common stumbling blocks. First, there may be times when you need to call #reload on an object after you've made database changes to ensure that you're getting a fresh…

Contents