lib/rubocop/cop/capybara/specific_matcher.rb in rubocop-capybara-2.19.0 vs lib/rubocop/cop/capybara/specific_matcher.rb in rubocop-capybara-2.20.0
- old
+ new
@@ -40,10 +40,15 @@
# @!method first_argument(node)
def_node_matcher :first_argument, <<-PATTERN
(send nil? _ (str $_) ... )
PATTERN
+ # @!method text_with_regexp?(node)
+ def_node_search :text_with_regexp?, <<-PATTERN
+ (pair (sym {:text :exact_text}) (regexp ...))
+ PATTERN
+
def on_send(node)
first_argument(node) do |arg|
next unless (matcher = specific_matcher(arg))
next if CssSelector.multiple_selectors?(arg)
next unless replaceable?(node, arg, matcher)
@@ -59,9 +64,10 @@
SPECIFIC_MATCHER[splitted_arg]
end
def replaceable?(node, arg, matcher)
replaceable_attributes?(arg) &&
+ !text_with_regexp?(node) &&
CapybaraHelp.replaceable_option?(node, arg, matcher) &&
CapybaraHelp.replaceable_pseudo_classes?(arg)
end
def replaceable_attributes?(selector)