Class: RuboCop::Cop::Capybara::AmbiguousClick

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/capybara/ambiguous_click.rb

Overview

Specify the exact target to click on.

In projects where accessibility needs to be considered, it is crucial to specify the click target precisely.

Examples:

# bad
click_link_or_button('foo')
click_on('foo')

# good
click_link('foo')
click_button('foo')

Constant Summary collapse

MSG =
'Use `click_link` or `click_button` instead of `%<method>s`.'
RESTRICT_ON_SEND =
%i[click_link_or_button click_on].freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object

[View source]

24
25
26
# File 'lib/rubocop/cop/capybara/ambiguous_click.rb', line 24

def on_send(node)
  add_offense(node, message: format(MSG, method: node.method_name))
end