class RuboCop::Cop::RSpec::VariableName
let(:userFood_2) { ‘fettuccine’ }
subject(:userFood_1) { ‘spaghetti’ }
# okay because it matches the ‘^userFood` regex in `IgnoredPatterns`
@example
# - ^userFood
# IgnoredPatterns:
# EnforcedStyle: snake_case
# RSpec/VariableName:
# rubocop.yml
@example IgnoredPatterns configuration
let(:userName2) { ’Adam’ }
subject(:userName1) { ‘Adam’ }
# good
let(:user_name_2) { ‘Adam’ }
subject(:user_name_1) { ‘Adam’ }
# bad
@example EnforcedStyle: camelCase
let(:user_name_2) { ‘Adam’ }
subject(:user_name_1) { ‘Adam’ }
# good
let(:userName2) { ‘Adam’ }
subject(:userName1) { ‘Adam’ }
# bad
@example EnforcedStyle: snake_case (default)
option.
Variables can be excluded from checking using the ‘IgnoredPatterns`
Checks that memoized helper names use the configured style.
def message(style)
def message(style) format(MSG, style: style) end
def on_send(node)
def on_send(node) variable_definition?(node) do |variable| return if variable.dstr_type? || variable.dsym_type? return if matches_ignored_pattern?(variable.value) check_name(node, variable.value, variable.loc.expression) end end