Class: RuboCop::Cop::RSpec::Capybara::SpecificFinders
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/rspec/capybara/specific_finders.rb
Overview
Checks if there is a more specific finder offered by Capybara.
Constant Summary collapse
- MSG =
'Prefer `find_by` over `find`.'
- RESTRICT_ON_SEND =
%i[find].freeze
Instance Method Summary collapse
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language::NodePattern
#block_pattern, #numblock_pattern, #send_pattern
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#find_argument(node) ⇒ Object
27 28 29 |
# File 'lib/rubocop/cop/rspec/capybara/specific_finders.rb', line 27 def_node_matcher :find_argument, <<~PATTERN (send _ :find (str $_) ...) PATTERN |
#on_send(node) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/rubocop/cop/rspec/capybara/specific_finders.rb', line 31 def on_send(node) find_argument(node) do |arg| next if CssSelector.multiple_selectors?(arg) on_attr(node, arg) if attribute?(arg) on_id(node, arg) if CssSelector.id?(arg) end end |