Merge pull request #15285 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-capybara-2.18.0
build(deps): bump rubocop-capybara from 2.17.1 to 2.18.0 in /Library/Homebrew
This commit is contained in:
commit
270abd8467
@ -142,7 +142,7 @@ GEM
|
|||||||
unicode-display_width (>= 2.4.0, < 3.0)
|
unicode-display_width (>= 2.4.0, < 3.0)
|
||||||
rubocop-ast (1.28.0)
|
rubocop-ast (1.28.0)
|
||||||
parser (>= 3.2.1.0)
|
parser (>= 3.2.1.0)
|
||||||
rubocop-capybara (2.17.1)
|
rubocop-capybara (2.18.0)
|
||||||
rubocop (~> 1.41)
|
rubocop (~> 1.41)
|
||||||
rubocop-performance (1.17.1)
|
rubocop-performance (1.17.1)
|
||||||
rubocop (>= 1.7.0, < 2.0)
|
rubocop (>= 1.7.0, < 2.0)
|
||||||
|
|||||||
@ -63,6 +63,7 @@ module RuboCop::Cop::Capybara::CssSelector
|
|||||||
end
|
end
|
||||||
|
|
||||||
class RuboCop::Cop::Capybara::CurrentPathExpectation < ::RuboCop::Cop::Base
|
class RuboCop::Cop::Capybara::CurrentPathExpectation < ::RuboCop::Cop::Base
|
||||||
|
include ::RuboCop::Cop::RangeHelp
|
||||||
extend ::RuboCop::Cop::AutoCorrector
|
extend ::RuboCop::Cop::AutoCorrector
|
||||||
|
|
||||||
def as_is_matcher(param0 = T.unsafe(nil)); end
|
def as_is_matcher(param0 = T.unsafe(nil)); end
|
||||||
@ -72,9 +73,11 @@ class RuboCop::Cop::Capybara::CurrentPathExpectation < ::RuboCop::Cop::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def add_argument_parentheses(corrector, arg_node); end
|
||||||
def add_ignore_query_options(corrector, node); end
|
def add_ignore_query_options(corrector, node); end
|
||||||
def autocorrect(corrector, node); end
|
def autocorrect(corrector, node); end
|
||||||
def convert_regexp_node_to_literal(corrector, matcher_node, regexp_node); end
|
def convert_regexp_node_to_literal(corrector, matcher_node, regexp_node); end
|
||||||
|
def method_call_with_no_parentheses?(arg_node); end
|
||||||
def regexp_node_to_regexp_expr(regexp_node); end
|
def regexp_node_to_regexp_expr(regexp_node); end
|
||||||
def rewrite_expectation(corrector, node, to_symbol, matcher_node); end
|
def rewrite_expectation(corrector, node, to_symbol, matcher_node); end
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
|
|||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-progressbar-1.13.0/lib")
|
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-progressbar-1.13.0/lib")
|
||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/unicode-display_width-2.4.2/lib")
|
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/unicode-display_width-2.4.2/lib")
|
||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-1.50.2/lib")
|
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-1.50.2/lib")
|
||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-capybara-2.17.1/lib")
|
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-capybara-2.18.0/lib")
|
||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-performance-1.17.1/lib")
|
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-performance-1.17.1/lib")
|
||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rails-2.19.1/lib")
|
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rails-2.19.1/lib")
|
||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-2.19.0/lib")
|
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-2.19.0/lib")
|
||||||
|
|||||||
@ -4,7 +4,7 @@ module RuboCop
|
|||||||
module Capybara
|
module Capybara
|
||||||
# Version information for the Capybara RuboCop plugin.
|
# Version information for the Capybara RuboCop plugin.
|
||||||
module Version
|
module Version
|
||||||
STRING = '2.17.1'
|
STRING = '2.18.0'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -6,10 +6,10 @@ module RuboCop
|
|||||||
# Checks that no expectations are set on Capybara's `current_path`.
|
# Checks that no expectations are set on Capybara's `current_path`.
|
||||||
#
|
#
|
||||||
# The
|
# The
|
||||||
# https://www.rubydoc.info/github/teamcapybara/capybara/main/Capybara/RSpecMatchers#have_current_path-instance_method[`have_current_path` matcher]
|
# https://www.rubydoc.info/github/teamcapybara/capybara/master/Capybara/RSpecMatchers#have_current_path-instance_method[`have_current_path` matcher]
|
||||||
# should be used on `page` to set expectations on Capybara's
|
# should be used on `page` to set expectations on Capybara's
|
||||||
# current path, since it uses
|
# current path, since it uses
|
||||||
# https://github.com/teamcapybara/capybara/blob/main/README.md#asynchronous-javascript-ajax-and-friends[Capybara's waiting functionality]
|
# https://github.com/teamcapybara/capybara/blob/master/README.md#asynchronous-javascript-ajax-and-friends[Capybara's waiting functionality]
|
||||||
# which ensures that preceding actions (like `click_link`) have
|
# which ensures that preceding actions (like `click_link`) have
|
||||||
# completed.
|
# completed.
|
||||||
#
|
#
|
||||||
@ -30,6 +30,7 @@ module RuboCop
|
|||||||
#
|
#
|
||||||
class CurrentPathExpectation < ::RuboCop::Cop::Base
|
class CurrentPathExpectation < ::RuboCop::Cop::Base
|
||||||
extend AutoCorrector
|
extend AutoCorrector
|
||||||
|
include RangeHelp
|
||||||
|
|
||||||
MSG = 'Do not set an RSpec expectation on `current_path` in ' \
|
MSG = 'Do not set an RSpec expectation on `current_path` in ' \
|
||||||
'Capybara feature specs - instead, use the ' \
|
'Capybara feature specs - instead, use the ' \
|
||||||
@ -85,8 +86,7 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
|
|
||||||
def rewrite_expectation(corrector, node, to_symbol, matcher_node)
|
def rewrite_expectation(corrector, node, to_symbol, matcher_node)
|
||||||
current_path_node = node.first_argument
|
corrector.replace(node.first_argument, 'page')
|
||||||
corrector.replace(current_path_node, 'page')
|
|
||||||
corrector.replace(node.parent.loc.selector, 'to')
|
corrector.replace(node.parent.loc.selector, 'to')
|
||||||
matcher_method = if to_symbol == :to
|
matcher_method = if to_symbol == :to
|
||||||
'have_current_path'
|
'have_current_path'
|
||||||
@ -94,6 +94,7 @@ module RuboCop
|
|||||||
'have_no_current_path'
|
'have_no_current_path'
|
||||||
end
|
end
|
||||||
corrector.replace(matcher_node.loc.selector, matcher_method)
|
corrector.replace(matcher_node.loc.selector, matcher_method)
|
||||||
|
add_argument_parentheses(corrector, matcher_node.first_argument)
|
||||||
add_ignore_query_options(corrector, node)
|
add_ignore_query_options(corrector, node)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -111,6 +112,20 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_argument_parentheses(corrector, arg_node)
|
||||||
|
return unless method_call_with_no_parentheses?(arg_node)
|
||||||
|
|
||||||
|
first_argument_range = range_with_surrounding_space(
|
||||||
|
arg_node.first_argument.source_range, side: :left
|
||||||
|
)
|
||||||
|
corrector.insert_before(first_argument_range, '(')
|
||||||
|
corrector.insert_after(arg_node.last_argument, ')')
|
||||||
|
end
|
||||||
|
|
||||||
|
def method_call_with_no_parentheses?(arg_node)
|
||||||
|
arg_node.send_type? && arg_node.arguments? && !arg_node.parenthesized?
|
||||||
|
end
|
||||||
|
|
||||||
# `have_current_path` with no options will include the querystring
|
# `have_current_path` with no options will include the querystring
|
||||||
# while `page.current_path` does not.
|
# while `page.current_path` does not.
|
||||||
# This ensures the option `ignore_query: true` is added
|
# This ensures the option `ignore_query: true` is added
|
||||||
@ -4,6 +4,7 @@ module RuboCop
|
|||||||
module Cop
|
module Cop
|
||||||
module Capybara
|
module Capybara
|
||||||
# Help methods for capybara.
|
# Help methods for capybara.
|
||||||
|
# @api private
|
||||||
module CapybaraHelp
|
module CapybaraHelp
|
||||||
COMMON_OPTIONS = %w[
|
COMMON_OPTIONS = %w[
|
||||||
id class style
|
id class style
|
||||||
@ -4,6 +4,7 @@ module RuboCop
|
|||||||
module Cop
|
module Cop
|
||||||
module Capybara
|
module Capybara
|
||||||
# Helps parsing css selector.
|
# Helps parsing css selector.
|
||||||
|
# @api private
|
||||||
module CssSelector
|
module CssSelector
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ module RuboCop
|
|||||||
CAPYBARA_MATCHERS = %w[
|
CAPYBARA_MATCHERS = %w[
|
||||||
selector css xpath text title current_path link button
|
selector css xpath text title current_path link button
|
||||||
field checked_field unchecked_field select table
|
field checked_field unchecked_field select table
|
||||||
sibling ancestor
|
sibling ancestor content
|
||||||
].freeze
|
].freeze
|
||||||
POSITIVE_MATCHERS =
|
POSITIVE_MATCHERS =
|
||||||
Set.new(CAPYBARA_MATCHERS) { |element| :"have_#{element}" }.freeze
|
Set.new(CAPYBARA_MATCHERS) { |element| :"have_#{element}" }.freeze
|
||||||
@ -75,7 +75,7 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
|
|
||||||
def offense_range(node, receiver)
|
def offense_range(node, receiver)
|
||||||
receiver.loc.selector.with(end_pos: node.loc.expression.end_pos)
|
receiver.loc.selector.with(end_pos: node.source_range.end_pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
def message(action, selector)
|
def message(action, selector)
|
||||||
@ -19,7 +19,7 @@ module RuboCop
|
|||||||
|
|
||||||
include RangeHelp
|
include RangeHelp
|
||||||
|
|
||||||
MSG = 'Prefer `find_by` over `find`.'
|
MSG = 'Prefer `find_by_id` over `find`.'
|
||||||
RESTRICT_ON_SEND = %i[find].freeze
|
RESTRICT_ON_SEND = %i[find].freeze
|
||||||
|
|
||||||
# @!method find_argument(node)
|
# @!method find_argument(node)
|
||||||
@ -68,7 +68,7 @@ module RuboCop
|
|||||||
def register_offense(node, id, classes = [])
|
def register_offense(node, id, classes = [])
|
||||||
add_offense(offense_range(node)) do |corrector|
|
add_offense(offense_range(node)) do |corrector|
|
||||||
corrector.replace(node.loc.selector, 'find_by_id')
|
corrector.replace(node.loc.selector, 'find_by_id')
|
||||||
corrector.replace(node.first_argument.loc.expression,
|
corrector.replace(node.first_argument,
|
||||||
id.delete('\\'))
|
id.delete('\\'))
|
||||||
unless classes.compact.empty?
|
unless classes.compact.empty?
|
||||||
autocorrect_classes(corrector, node, classes)
|
autocorrect_classes(corrector, node, classes)
|
||||||
@ -117,7 +117,7 @@ module RuboCop
|
|||||||
if node.loc.end
|
if node.loc.end
|
||||||
node.loc.end.end_pos
|
node.loc.end.end_pos
|
||||||
else
|
else
|
||||||
node.loc.expression.end_pos
|
node.source_range.end_pos
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user