Rspec 3弃用警告:不推荐使用example_group子分区过滤。 请使用subhash直接过滤

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

不推荐使用:example_group subhash进行过滤。 请使用subhash直接过滤。 从/path/to/file.rb:6:in`block in’调用。

不推荐使用:example_group subhash进行过滤。 请使用subhash直接过滤。 从/path/to/file.rb:8:in`block in’调用。

从path /到/ 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:{}’(见下文)?

 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

有关原因的完整说明,请参阅此提交,但简而言之,他们认为当示例组的元数据具有关键的example_group时,该哈希仅具有示例组的元数据,这让人感到困惑