rspec 描述 rake 任务命名空间

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

我想测试 rake 任务的特定命名空间,但我从 rubocop 收到错误。

desc 'This namespace is test'
namespace :test_namespace do

  task test_task: :environment do

在我的耙子任务中,我有以下内容

RSpec.describe 'test_namespace' do
  describe 'test_task' do

上面给了我一个错误

The first argument to describe should be the class or module being tested.
ruby-on-rails rspec rake
2个回答
0
投票

您只需将类直接传递到测试的描述行,而不是字符串。对于你的情况:

RSpec.describe TestNamespace do

0
投票

添加类型::任务修复 rubocop 错误
示例:

describe 'some task description', type: :task do
  # test case here
end
© www.soinside.com 2019 - 2024. All rights reserved.