class RuboCop::Cop::RSpec::VariableName
let(:userFood_2) { ‘fettuccine’ }
subject(:userFood_1) { ‘spaghetti’ }
# okay because it matches the ‘^userFood` regex in `AllowedPatterns`
@example
# - ^userFood
# AllowedPatterns:
# EnforcedStyle: snake_case
# RSpec/VariableName:
# rubocop.yml
@example AllowedPatterns 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 ‘AllowedPatterns`
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) return unless inside_example_group?(node) variable_definition?(node) do |variable| return if variable.type?(:dstr, :dsym) return if matches_allowed_pattern?(variable.value) check_name(node, variable.value, variable.source_range) end end