This repository was archived by the owner on Nov 30, 2024. It is now read-only.
Fix filtering based on :example_group
to work for example groups.
#2234
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This regressed in #1749. The changes there affected code like this:
In RSpec 2, and in RSpec 3 before #1749, this snippet would cause
Mod
to be included in every example group (since
/./
matches all filepaths). After #1749, it would not be included in any example groups.
Instead, it was included in the singleton class of every example.
In practice, this usually worked OK, as the methods from
Mod
wereavailable to be called very every example, but it had subtle problems:
the version of the method defined in a module included in this
fashion would always get precedence due to the singleton class
getting "first dibs" during method dispatch over the example group
class. (This is the broken example given in example_group is not longer supported #2232).
c.extend Mod, :example_group => {...}
sincewe don't extend onto singleton classes.
The reason is that the optimizations included in #1749 considered
only metadata keys that the groups and examples have in their metadata
hashes. In a group hash,
:example_group
is not a "real" metadatakey--instead it is created lazily on first access using a
default_proc
. But example hashes still have it (it is a reference tothe metadata of their group), so it allowed example filtering to work
correctly, which in turn hid the bug.
Fixes #2232.