Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 447
SamuelLJohnson Avatar asked Aug 18 '14 17:08

SamuelLJohnson


1 Answers

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

like image 98
Frederick Cheung Avatar answered Oct 15 '22 02:10

Frederick Cheung