rubocop-rspec
rubocop-rspec copied to clipboard
Add named_only style for RSpec/NamedSubject cop
This adds named_only style for the RSpec/NamedSubject cop. It is intended as a smaller step to first catch explicit subject references where the subject(:name) { .. } is named.
We keep the default style (I have named it always).
Before submitting the PR make sure the following are checked:
- [x] Feature branch is up-to-date with
master(if not - rebase it). - [x] Squashed related commits together.
- [x] Added tests.
- [x] Updated documentation.
- [x] Added an entry to the
CHANGELOG.mdif the new code introduces user-observable changes. - [x] The build (
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 modified an existing cop's configuration options:
- [x] Set
VersionChangedindefault/config.ymlto the next major version.
@pirj Thanks for the nice review ! I have added changes as requested, please see each thread above.
Nice addition. Any release planned soon?
Should this cop also ignore implicit subjects?
This would be useful when is_expected is not recommanded by RSpec/ImplicitSubject and no explicit subject is defined.
RSpec.describe Klass do
it do
prepare_something_to_be_true
expect(subject).to be_something
end
end
Thanks for the bump, @inkstak . Let me quickly rebase it.
@bquorning @Darhazer WDYT?
@bquorning I won't be merging this so far, not to interfere with the release.
Thank you, @kuahyeow ! Please accept our apologies it took two years to merge.