Skip to content

Commit 817a77e

Browse files
committed
RSpec/SubjectStub. Code review. Refactor #find_all_named_subjects method
1 parent 20e37fb commit 817a77e

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/rubocop/cop/rspec/subject_stub.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,10 @@ def processed_example_groups
102102
end
103103

104104
def find_all_named_subjects(node)
105-
named_subjects = {}
106-
107-
node.each_descendant(:block) do |child|
105+
node.each_descendant(:block).each_with_object({}) do |child, h|
108106
name = subject(child)
109-
named_subjects[child.parent.parent] = name if name
107+
h[child.parent.parent] = name if name
110108
end
111-
112-
named_subjects
113109
end
114110

115111
def find_subject_expectations(node, subject_name = nil, &block)

0 commit comments

Comments
 (0)