Skip to content

Commit

Permalink
Merge pull request #1170 from dswij/subject-declaration-cop
Browse files Browse the repository at this point in the history
Add SubjectDeclaration cop
  • Loading branch information
pirj committed Jul 28, 2021
2 parents 1a8c891 + 45e89ad commit d833041
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Fix each example for `RSpec/HookArgument`. ([@lokhi][])
* Exclude unrelated Rails directories from `RSpec/DescribeClass`. ([@MothOnMars][])
* Add `RSpec/ExcessiveDocstringSpacing` cop. ([@G-Rath][])
* Add `RSpec/SubjectDeclaration` cop. ([@dswij][])

## 2.4.0 (2021-06-09)

Expand Down Expand Up @@ -632,3 +633,4 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
[@lokhi]: https://github.com/lokhi
[@MothOnMars]: https://github.com/MothOnMars
[@G-Rath]: https://github.com/G-Rath
[@dswij]: https://github.com/dswij
6 changes: 6 additions & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,12 @@ RSpec/StubbedMock:
VersionAdded: '1.44'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/StubbedMock

RSpec/SubjectDeclaration:
Description: Ensure that subject is defined using subject helper.
Enabled: pending
VersionAdded: '2.5'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SubjectDeclaration

RSpec/SubjectStub:
Description: Checks for stubbed test subjects.
Enabled: true
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/cops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
* xref:cops_rspec.adoc#rspecsharedexamples[RSpec/SharedExamples]
* xref:cops_rspec.adoc#rspecsingleargumentmessagechain[RSpec/SingleArgumentMessageChain]
* xref:cops_rspec.adoc#rspecstubbedmock[RSpec/StubbedMock]
* xref:cops_rspec.adoc#rspecsubjectdeclaration[RSpec/SubjectDeclaration]
* xref:cops_rspec.adoc#rspecsubjectstub[RSpec/SubjectStub]
* xref:cops_rspec.adoc#rspecunspecifiedexception[RSpec/UnspecifiedException]
* xref:cops_rspec.adoc#rspecvariabledefinition[RSpec/VariableDefinition]
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/rspec_rails_cops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
require_relative 'rspec/shared_examples'
require_relative 'rspec/single_argument_message_chain'
require_relative 'rspec/stubbed_mock'
require_relative 'rspec/subject_declaration'
require_relative 'rspec/subject_stub'
require_relative 'rspec/unspecified_exception'
require_relative 'rspec/variable_definition'
Expand Down

0 comments on commit d833041

Please sign in to comment.