File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -96,17 +96,19 @@ def processed_example_groups
9696 def find_all_explicit_subjects ( node )
9797 node . each_descendant ( :block ) . each_with_object ( { } ) do |child , h |
9898 name = subject ( child )
99- if name
100- h [ child . parent . parent ] ||= [ ]
101- h [ child . parent . parent ] << name
99+ next unless name
100+
101+ outer_example_group = child . each_ancestor . find do |a |
102+ example_group? ( a )
102103 end
104+
105+ h [ outer_example_group ] ||= [ ]
106+ h [ outer_example_group ] << name
103107 end
104108 end
105109
106110 def find_subject_expectations ( node , subject_names = [ ] , &block )
107- if example_group? ( node ) && @explicit_subjects [ node ]
108- subject_names = @explicit_subjects [ node ]
109- end
111+ subject_names = @explicit_subjects [ node ] if @explicit_subjects [ node ]
110112
111113 expectation_detected = ( subject_names + [ :subject ] ) . any? do |name |
112114 message_expectation? ( node , name )
Original file line number Diff line number Diff line change 2121 end
2222
2323 it 'flags when subject is stubbed and there are several named subjects ' \
24- 'in the same example group' , :wip do
24+ 'in the same example group' do
2525 expect_offense ( <<-RUBY )
2626 describe Foo do
2727 subject(:foo) { described_class.new }
You can’t perform that action at this time.
0 commit comments