简体   繁体   English

Rspec / DescribeClass上的Rubocop错误

[英]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: 由于previos版本中的错误,我最近已将Rubocop(0.51)更新为最新版本,但现在将以下内容标记为错误:

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. 我的spec文件夹中的所有文件都发生了相同的情况。 They all have the correspondent class name. 它们都有对应的类名。

I've managed to fix the erro by updating rubocop-rspec version. 我已经设法通过更新rubocop-rspec版本来修复错误。

It was version 1.10 and updated it to 1.20.1 the error did not show again. 它是版本1.10,并将其更新为1.20.1,该错误不再显示。

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 你的情况是:type => :controller

Example: 例:

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

for more information you can visit the following link Rspec Controllers 有关更多信息,您可以访问以下链接Rspec控制器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM