Class: RuboCop::Cop::Airbnb::SpecConstantAssignment
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Airbnb::SpecConstantAssignment
- Defined in:
- lib/rubocop/cop/airbnb/spec_constant_assignment.rb
Overview
This cop checks for constant assignment inside of specs
Constant Summary collapse
- MESSAGE =
"Defining constants inside of specs can cause spurious behavior. " \ "It is almost always preferable to use `let` statements, " \ "anonymous class/module definitions, or stub_const".freeze
Instance Method Summary collapse
Instance Method Details
#on_casgn(node) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/rubocop/cop/airbnb/spec_constant_assignment.rb', line 33 def on_casgn(node) return unless in_spec_file?(node) parent_module_name = node.parent_module_name if parent_module_name && parent_module_name != "Object" return end add_offense(node, message: MESSAGE) end |