Update RSpec/SharedExamples to allow specifying a preferred method to use for defining and including shared examples and context#2062
Conversation
| elsif Includes.context(method_name) | ||
| # :nocov: - simplecov is not detecting the coverage of this branch! | ||
| cop_config['PreferredIncludeContextMethod'] | ||
| # :nocov: | ||
| end |
There was a problem hiding this comment.
I'm unclear as to why, but simplecov doesn't think this branch is covered, even though it is (line 270 of the spec).
|
Failing edge rubocop check is fixed in #2063. |
|
Nice! Glancing over, it feels this would better be a separate cop. Do you have a specific reason to modify the existing one? Once concern that comes to mind is that new cops are pending by default. We're releasing major versions more often, and in less than a year this cop will be enabled for everyone. |
|
@pirj ha! I went back and forth on if it should enhance the existing cop or create a new one. I settled on updating because |
…to use for defining and including shared examples and context
313e4e5 to
9144216
Compare
|
I don't think we had a chance to adjust cop names to follow the cop naming guidelines, but I'd call those two |
|
How about for these changes |
|
I'll open a new PR with the new cop. |
Allows
RSpec/SharedExamplesto be configured with preferred methods for defining and including shared examples and context, so that consistency can be enforced.Follows rubocop/rubocop#14033.
Before submitting the PR make sure the following are checked:
master(if not - rebase it).CHANGELOG.mdif the new code introduces user-observable changes.bundle exec rake) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).If you have created a new cop:
config/default.yml.Enabled: pendinginconfig/default.yml.Enabled: truein.rubocop.yml.VersionAdded: "<<next>>"indefault/config.yml.If you have modified an existing cop's configuration options:
VersionChanged: "<<next>>"inconfig/default.yml.