Passing RSPEC Tests for a Rails Validation Error

Last Updated: February 07, 2018

Passing RSPEC Tests for a Rails Validation Error

Launch School Course 3 is all about testing baby. The assignment was to write up a test to make sure your validation errors were working. I haven’t looked at the solution video yet, but mine passed with flying colors.

The first code snippet below is my validations inside of the Video model. You can see that I’m requiring the presence of a title and a description.

The second code snippet is the creation(and subsequent saving via the .create method) of a video instance. The first one lacks a title, the second lacks a description.

To make sure that the validations were occurring, I took a peek at the first, and only, full message error of the video instance that I was trying to create, hence the [0] array index.

After dealing with a typo in my test, I got everything working.

The tests passed! Validations are firing!