Class: RuboCop::Cop::RSpec::Capybara::SpecificMatcher
- Defined in:
- lib/rubocop/cop/rspec/capybara/specific_matcher.rb
Overview
Checks for there is a more specific matcher offered by Capybara.
Constant Summary collapse
- MSG =
'Prefer `%<good_matcher>s` over `%<bad_matcher>s`.'
- RESTRICT_ON_SEND =
%i[have_selector have_no_selector have_css have_no_css].freeze
- SPECIFIC_MATCHER =
{ 'button' => 'button', 'a' => 'link', 'table' => 'table', 'select' => 'select' }.freeze
Instance Method Summary collapse
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language::NodePattern
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#first_argument(node) ⇒ Object
39 40 41 |
# File 'lib/rubocop/cop/rspec/capybara/specific_matcher.rb', line 39 def_node_matcher :first_argument, <<-PATTERN (send nil? _ (str $_) ... ) PATTERN |
#on_send(node) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/rubocop/cop/rspec/capybara/specific_matcher.rb', line 43 def on_send(node) return unless (arg = first_argument(node)) return unless (matcher = specific_matcher(arg)) return if acceptable_pattern?(arg) add_offense(node, message: (node, matcher)) end |