Our First Test using RSpec

Learn to generate a test for our User model in this lesson.

Generating spec for our User model

Having installed RSpec in our project, it is not very satisfying to see zero tests running. Let’s rectify that right now by creating our first test so that we can see some actual test code running.

To generate a spec for our User model, we have used:

$ docker-compose exec web bin/rails generate rspec:model user
create spec/models/user_spec.rb

File user_spec.rb

The newly created spec/models/user_spec.rb file looks like this:

require 'rails_helper'

RSpec.describe User, type: :model do
  pending "add some examples to (or delete) #{__FILE__}"
end

The following modification should do the trick:

Get hands-on with 1400+ tech skills courses.