Rspec 3 弃用警告:不推荐使用 example_group 子哈希进行过滤.使用 subhash 直接过滤 [英] Rspec 3 Deprecation Warning: Filtering by an example_group subhash is deprecated. Use the subhash to filter directly instead

查看:34
本文介绍了Rspec 3 弃用警告:不推荐使用 example_group 子哈希进行过滤.使用 subhash 直接过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行我的 Rspec 版本 3 测试时,我收到以下弃用警告:

When running my Rspec version 3 tests, I get the following deprecation warnings:

不推荐使用 :example_group 子哈希过滤.使用 subhash 直接过滤.从/path/to/file.rb:6:in `block in ' 调用.

Filtering by an :example_group subhash is deprecated. Use the subhash to filter directly instead. Called from /path/to/file.rb:6:in `block in '.

不推荐使用 :example_group 子哈希过滤.使用 subhash 直接过滤.从/path/to/file.rb:8:in `block in ' 调用.

Filtering by an :example_group subhash is deprecated. Use the subhash to filter directly instead. Called from /path/to/file.rb:8:in `block in '.

从路径/到/file.rb:

From path/to/file.rb:

RSpec.configure do |config|
  module MyCodeHelpers
   #
  end

  config.include MyCodeHelpers, example_group: { :file_path => %r(spec/services/my_code) }

  config.before(:all, example_group: { :file_path => %r(spec/services/my_code) }) do
    @stub = true
  end
end

这是否仅仅意味着删除 :file_path 值周围的example_group: {}"(见下文)?

Does this simply mean removing the 'example_group: {}' around the :file_path value (see below)?

config.include MyCodeHelpers, :file_path => %r(spec/services/my_code)

config.before(:all, :file_path => %r(spec/services/my_code)) do
  @stub = true
end

推荐答案

是的,这正是它所说的.它适用于设置元数据和使用元数据时,通过查询或使用它来过滤 config.include

Yes, that is exactly what it's saying. It applies both when you are setting metadata and when you are using the metadata, either by querying it or using it to filter a config.include

有关原因的完整说明,请参阅此提交但简而言之他们认为示例组的元数据具有键 example_group 会令人困惑,而该散列只有示例组的元数据

For a full explanation of why, see this commit but in a nutshell they thought it was confusing for an example group's metadata to have a key example_group when that hash only has metadata for the example group

这篇关于Rspec 3 弃用警告:不推荐使用 example_group 子哈希进行过滤.使用 subhash 直接过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆