class RuboCop::Cop::Capybara::ClickLinkOrButtonStyle


click_button(‘foo’)
click_link(‘foo’)
# good
click_on(‘foo’)
click_link_or_button(‘foo’)
# bad
@example EnforcedStyle: strict
click_on(‘foo’)
click_link_or_button(‘foo’)
# good
click_button(‘foo’)
click_link(‘foo’)
# bad
@example EnforcedStyle: link_or_button (default)
‘click_link` and `click_button`, but this is a deprecated setting.
You can set `EnforcedStyle: strict` to prefer the use of
allowing for a more faithful reflection of how the user behaves.
These methods offer a weaker coupling between the test and HTML,
By default, prefer to use `click_link_or_button` or `click_on`.
There is no migration target when `EnforcedStyle: link_or_button`.
If you are using this cop, please plan for migration.
It is only migration target when `EnforcedStyle: strict`.
The migration target is `Capybara/AmbiguousClick`.
We plan to remove this in the next major version update to 3.0.
This cop is deprecated.
Checks for methods of button or link clicks.

def link_or_button_method?(node)

def link_or_button_method?(node)
  CLICK_LINK_OR_BUTTON.include?(node.method_name)
end

def offense?(node)

def offense?(node)
  (style == :strict && !strict_method?(node)) ||
    (style == :link_or_button && !link_or_button_method?(node))
end

def offense_message(node)

def offense_message(node)
  if style == :strict
    format(MSG_STRICT, method: node.method_name)
  elsif style == :link_or_button
    format(MSG_CLICK_LINK_OR_BUTTON, method: node.method_name)
  else
    # :nocov:
    :noop
    # :nocov:
  end
end

def on_send(node)

def on_send(node)
  return unless offense?(node)
  add_offense(node, message: offense_message(node))
end

def strict_method?(node)

def strict_method?(node)
  STRICT_METHODS.include?(node.method_name)
end