Skip to content

Commit

Permalink
Merge pull request #1376 from ydah/support_subject!
Browse files Browse the repository at this point in the history
Add support for subject! method to `RSpec/SubjectDeclaration`
  • Loading branch information
pirj authored Oct 23, 2022
2 parents 1c4b245 + 63a09d7 commit 3a43b8e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
- Update `config/default.yml` removing deprecated option to make the config correctable by users. ([@ignaciovillaverde])
- Do not attempt to auto-correct example groups with `include_examples` in `RSpec/LetBeforeExamples`. ([@pirj])
- Add new `RSpec/SortMetadata` cop. ([@leoarnold])
* Add `require_implicit` style to `RSpec/ImplicitSubject`. ([@r7kamura][])
* Fix a false positive for `RSpec/Capybara/SpecificMatcher` when `have_css("a")` without attribute. ([@ydah][])
* Add support for subject! method to `RSpec/SubjectDeclaration`. ([@ydah][])

## 2.13.2 (2022-09-23)

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/subject_declaration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SubjectDeclaration < Base

# @!method offensive_subject_declaration?(node)
def_node_matcher :offensive_subject_declaration?, <<~PATTERN
(send nil? ${#Subjects.all #Helpers.all} {(sym :subject) (str "subject")} ...)
(send nil? ${#Subjects.all #Helpers.all} {(sym #Subjects.all) (str #Subjects.all)} ...)
PATTERN

def on_send(node)
Expand Down
2 changes: 2 additions & 0 deletions spec/rubocop/cop/rspec/subject_declaration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@

include_examples 'flag unclear subject declaration', :subject
include_examples 'flag unclear subject declaration', 'subject'
include_examples 'flag unclear subject declaration', :subject!
include_examples 'flag unclear subject declaration', 'subject!'

context 'when subject helper is used directly' do
it 'does not register an offense on named subject' do
Expand Down

0 comments on commit 3a43b8e

Please sign in to comment.