Rspec 3 Deprecation Warning: Filtering by an example_group subhash is deprecated. Use the subhash to filter directly instead

喜欢而已 提交于 2020-01-02 03:10:07

问题


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

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 '.

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 '.

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

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)

and

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

回答1:


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

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



来源:https://stackoverflow.com/questions/25369127/rspec-3-deprecation-warning-filtering-by-an-example-group-subhash-is-deprecated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!