-
-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider changing the semantics of shared example group metadata #1790
Comments
One other thing -- if we did this, I don't think we'd have to do anything to address #1762 as this would take care of that issue as well. |
I like this idea, I use
I'm fine with this, it's similar to how we changed the metadata symbol means true stuff in RSpec 2 -> 3. How about make the config option a "behaviour" rather than a on / off flag? |
One update to this idea: we could consider making |
Then it's switching behaviour based on type of the argument? I'm slightly negative on that.
I lean towards the former. This doesn't seem important enough to justify introducing more config, RSpec 4 is in theory not that far away (... any reason we shouldn't just call master 4 and start working on it?), and there would be a way to transition to the new behaviour with |
I wouldn't consider it switching behavior. Ultimately it's including a module -- either a manually defined and referenced one from the user, or a |
This simplifies things, makes things more consistent, and prepares us to be able to better handle metadata as per discussion in #1790.
- Takes care of preserving metadata inheritance. - Takes care of re-applying filtered config items like module inclusions and hooks. This is necessary for #1790.
Previously, it always triggered auto-inclusion based on matching metadata. The option allows you to opt-in to having it add the metadata to included groups and examples instead. - Closes #1790 (this is the last thing necessary for it). - Addresses #1762. - Addresses user confusion reported in: - rspec/rspec-rails#1241 - rspec/rspec-rails#1579
Previously, it always triggered auto-inclusion based on matching metadata. The option allows you to opt-in to having it add the metadata to included groups and examples instead. - Closes #1790 (this is the last thing necessary for it). - Addresses #1762. - Addresses user confusion reported in: - rspec/rspec-rails#1241 - rspec/rspec-rails#1579
Previously, it always triggered auto-inclusion based on matching metadata. The option allows you to opt-in to having it add the metadata to included groups and examples instead. - Closes #1790 (this is the last thing necessary for it). - Addresses #1762. - Addresses user confusion reported in: - rspec/rspec-rails#1241 - rspec/rspec-rails#1579
Previously, it always triggered auto-inclusion based on matching metadata. The option allows you to opt-in to having it add the metadata to included groups and examples instead. - Closes #1790 (this is the last thing necessary for it). - Addresses #1762. - Addresses user confusion reported in: - rspec/rspec-rails#1241 - rspec/rspec-rails#1579
Previously, it always triggered auto-inclusion based on matching metadata. The option allows you to opt-in to having it add the metadata to included groups and examples instead. - Closes #1790 (this is the last thing necessary for it). - Addresses #1762. - Addresses user confusion reported in: - rspec/rspec-rails#1241 - rspec/rspec-rails#1579
- Takes care of preserving metadata inheritance. - Takes care of re-applying filtered config items like module inclusions and hooks. This is necessary for #1790.
This simplifies things, makes things more consistent, and prepares us to be able to better handle metadata as per discussion in rspec#1790.
- Takes care of preserving metadata inheritance. - Takes care of re-applying filtered config items like module inclusions and hooks. This is necessary for rspec#1790.
Previously, it always triggered auto-inclusion based on matching metadata. The option allows you to opt-in to having it add the metadata to included groups and examples instead. - Closes rspec#1790 (this is the last thing necessary for it). - Addresses rspec#1762. - Addresses user confusion reported in: - rspec/rspec-rails#1241 - rspec/rspec-rails#1579
Currently, you can tag a shared example group definition with some metadata:
...and that will cause the shared example group to be automatically included in matching example groups:
This works fine (and was originally my idea, IIRC), but I've realized a few problems with it:
shared_context
(the shared group name) is superfluous. It feels a bit like "what's this argument for again?" (Note that you could still use it withinclude_context
to include the group manually, but it's a bit odd to mix-and-match the approaches).:focus
,:skip
or:pending
metadata to a shared example group so that that behavior applies to all inclusions of the shared group.before
hook orlet
you want to make available everywhere...). You could do something likeRSpec.shared_context "...", :description => //
, since//
will match the description of every example group, but that's pretty indirect and non-obvious.config.include mod, *metadata
).I think we can rectify all of these with a few simple changes:
config.include_context
API that is similar toconfig.include
but is for shared contexts. This would solve the "no obvious way to auto-include a shared group everywhere" issue mentioned above and provide a sister API toconfig.include
for consistency.shared_context
as a means to determine which example groups should have the context auto-included, instead allowing it the metadata to get applied to including example groups.The first change is a new API and could be made in any 3.x release. The latter is a breaking change and either has to wait until RSpec 4 or we have to add a config option. I lean towards the latter -- something like
config.use_shared_example_group_metadata_for_auto_inclusion = true
(although that is a bit ambiguous -- theconfig.include_context
API would still use it for auto-inclusion -- maybe someone has a better idea?)Thoughts?
/cc @rspec/rspec
The text was updated successfully, but these errors were encountered: