fedest
fedest

Reputation: 1350

Rubocop error on Rspec/DescribeClass

I've recently updated to the most recent version of Rubocop (0.51) due to a bug in the previos version, but now it marks the following as error:

spec/controllers/loans_controller_spec.rb:3:10: C: RSpec/DescribeClass: The first argument to describe should be the class or module being tested.
describe LoansController do
         ^^^^^^^^^^^^^^^

This is the way I've been doing it since forever, and is in fact the class I want to test.

The same is happening with all files in my spec folder. They all have the correspondent class name.

Upvotes: 1

Views: 1244

Answers (2)

fedest
fedest

Reputation: 1350

I've managed to fix the erro by updating rubocop-rspec version.

It was version 1.10 and updated it to 1.20.1 the error did not show again.

Upvotes: 2

you have to specify that the class you are testing is a controller, after the reference to the class you must specify what kind of class it is. In your case it would be :type => :controller

Example:

RSpec.describe LoansController, :type => :controller do
end

for more information you can visit the following link Rspec Controllers

Upvotes: 0

Related Questions