lib/rubocop/cop/rspec/leading_subject.rb in rubocop-rspec-2.7.0 vs lib/rubocop/cop/rspec/leading_subject.rb in rubocop-rspec-2.8.0
- old
+ new
@@ -31,15 +31,17 @@
# it { expect_something }
# it { expect_something_else }
#
class LeadingSubject < Base
extend AutoCorrector
+ include InsideExampleGroup
MSG = 'Declare `subject` above any other `%<offending>s` declarations.'
def on_block(node)
- return unless subject?(node) && !in_spec_block?(node)
+ return unless subject?(node)
+ return unless inside_example_group?(node)
check_previous_nodes(node)
end
def check_previous_nodes(node)
@@ -75,15 +77,9 @@
let?(node) ||
hook?(node) ||
example?(node) ||
spec_group?(node) ||
include?(node)
- end
-
- def in_spec_block?(node)
- node.each_ancestor(:block).any? do |ancestor|
- example?(ancestor)
- end
end
end
end
end
end