Rspec / DescribeClass上的Rubocop错误

问题描述 投票:0回答:2

由于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
         ^^^^^^^^^^^^^^^

这是我永远这样做的方式,实际上是我想要测试的类。

我的spec文件夹中的所有文件都发生了同样的情况。他们都有相应的班级名称。

ruby-on-rails rspec rubocop rubocop-rspec
2个回答
1
投票

我已经设法通过更新rubocop-rspec版本来修复错误。

它是版本1.10并更新为1.20.1错误没有再显示。


0
投票

你必须指定你正在测试的类是一个控制器,在引用类之后你必须指定它是什么类。在你的情况下,它将是:type => :controller

例:

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

有关更多信息,请访问以下链接Rspec Controllers

© www.soinside.com 2019 - 2024. All rights reserved.