lib/rubocop/cop/rspec/multiple_subjects.rb in rubocop-rspec-1.32.0 vs lib/rubocop/cop/rspec/multiple_subjects.rb in rubocop-rspec-1.33.0
- old
+ new
@@ -32,12 +32,14 @@
#
# - If subjects are defined with `subject!` then we don't autocorrect.
# 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
+ include RangeHelp
+ MSG = 'Do not set more than one subject per example group'
+
def on_block(node)
return unless example_group?(node)
subjects = RuboCop::RSpec::ExampleGroup.new(node).subjects
@@ -68,10 +70,12 @@
end
end
def remove_autocorrect(node)
lambda do |corrector|
- corrector.remove(node.loc.expression)
+ range = range_by_whole_lines(node.source_range,
+ include_final_newline: true)
+ corrector.remove(range)
end
end
end
end
end