lib/rubocop/cop/rspec/multiple_subjects.rb in rubocop-rspec-1.27.0 vs lib/rubocop/cop/rspec/multiple_subjects.rb in rubocop-rspec-1.28.0
- old
+ new
@@ -34,14 +34,10 @@
# This is enough of an edge case that people can just move this to
# a `before` hook on their own
class MultipleSubjects < Cop
MSG = 'Do not set more than one subject per example group'.freeze
- def_node_matcher :named_subject?, <<-PATTERN
- (block (send nil? :subject $sym) args ...)
- PATTERN
-
def on_block(node)
return unless example_group?(node)
subjects = RuboCop::RSpec::ExampleGroup.new(node).subjects
@@ -59,9 +55,13 @@
remove_autocorrect(node)
end
end
private
+
+ def named_subject?(node)
+ node.send_node.arguments?
+ end
def rename_autocorrect(node)
lambda do |corrector|
corrector.replace(node.send_node.loc.selector, 'let')
end