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.

Writing specs

Writing specs - Ruby Tutorial

From the course: Ruby: Testing with RSpec

Start my 1-month free trial

Writing specs

- Now that we understand the basic syntax of our spec, we're ready to put it into practice, and actually write the specs that are going to go into our Car Spec file. I've gone ahead and pasted in some code, that we can look at to understand how these work. So we don't actually have to write it in real time. We've still got our require car line at top, that's going to make sure that we have the Car class available to us for our tests. It's going to be very important if we're going to test the class, we need to actually have it there. Then we've got our first example group, describe. And everything from do, down to end, is part of that example group. Then I've got three more nested example groups inside there, again, this is a matter of personal preference. I've got one for the attributes, you can go back and look at our file, you see I've got all these attribute accessors, and readers and writers. So I've got those there. That's what I'm going to be testing with that. I've got another…

Contents