class RuboCop::Cop::RSpec::Capybara::FeatureMethods

end
end
# …
it ‘with OAuth’ do
end
visit new_session_path
before do
let(:user) { User.new }
describe ‘User logs in’ do
# good
end
end
# …
scenario ‘with OAuth’ do
end
visit new_session_path
background do
given(:user) { User.new }
feature ‘User logs in’ do
# bad
@example
be enabled by using the EnabledMethods configuration option.
(alias for ‘before`), etc. You can configure which of the methods to
the rest of the methods, like `given` (alias for `let`), `background`
to make it obvious that the test uses Capybara, while still disable
however may prefer using some of the Capybara methods (like `feature`)
the same native RSpec method (e.g. are just aliases). Some teams
By default, the cop disables all Capybara-specific methods that have
Checks for consistent method usage in feature specs.

def enabled?(method_name)

def enabled?(method_name)
  enabled_methods.include?(method_name)
end

def enabled_methods

def enabled_methods
  cop_config
    .fetch('EnabledMethods', [])
    .map(&:to_sym)
end

def inside_spec?(node)

def inside_spec?(node)
  return spec?(node) if root_node?(node)
  root = node.ancestors.find { |parent| root_node?(parent) }
  spec?(root)
end

def message(range)

def message(range)
  name = range.source.to_sym
  format(MSG, method: name, replacement: MAP[name])
end

def on_block(node)

def on_block(node)
  return unless inside_spec?(node)
  feature_method(node) do |send_node, match|
    next if enabled?(match)
    add_offense(send_node.loc.selector) do |corrector|
      corrector.replace(send_node.loc.selector, MAP[match].to_s)
    end
  end
end

def root_node?(node)

def root_node?(node)
  node.parent.nil? || root_with_siblings?(node.parent)
end

def root_with_siblings?(node)

def root_with_siblings?(node)
  node.begin_type? && node.parent.nil?
end