问题
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