lib/rubocop/cop/capybara/specific_finders.rb in rubocop-capybara-2.17.1 vs lib/rubocop/cop/capybara/specific_finders.rb in rubocop-capybara-2.18.0

- old
+ new

@@ -17,11 +17,11 @@ class SpecificFinders < ::RuboCop::Cop::Base extend AutoCorrector include RangeHelp - MSG = 'Prefer `find_by` over `find`.' + MSG = 'Prefer `find_by_id` over `find`.' RESTRICT_ON_SEND = %i[find].freeze # @!method find_argument(node) def_node_matcher :find_argument, <<~PATTERN (send _ :find (str $_) ...) @@ -66,11 +66,11 @@ end def register_offense(node, id, classes = []) add_offense(offense_range(node)) do |corrector| corrector.replace(node.loc.selector, 'find_by_id') - corrector.replace(node.first_argument.loc.expression, + corrector.replace(node.first_argument, id.delete('\\')) unless classes.compact.empty? autocorrect_classes(corrector, node, classes) end end @@ -115,10 +115,10 @@ def end_pos(node) if node.loc.end node.loc.end.end_pos else - node.loc.expression.end_pos + node.source_range.end_pos end end end end end