Class: RuboCop::Cop::RSpec::RemoveConst
- Includes:
- RSpec::Language
- Defined in:
- lib/rubocop/cop/rspec/remove_const.rb
Overview
Checks that ‘remove_const` is not used in specs.
Constant Summary collapse
- MSG =
'Do not use remove_const in specs. ' \ 'Consider using e.g. `stub_const`.'
- RESTRICT_ON_SEND =
%i[send __send__].freeze
Instance Method Summary collapse
-
#on_send(node) ⇒ Object
Check for offenses.
- #remove_const(node) ⇒ Object
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Methods inherited from Base
inherited, #on_new_investigation
Instance Method Details
#on_send(node) ⇒ Object
Check for offenses
31 32 33 34 35 |
# File 'lib/rubocop/cop/rspec/remove_const.rb', line 31 def on_send(node) remove_const(node) do add_offense(node) end end |
#remove_const(node) ⇒ Object
26 27 28 |
# File 'lib/rubocop/cop/rspec/remove_const.rb', line 26 def_node_matcher :remove_const, <<~PATTERN (send _ {:send | :__send__} (sym :remove_const) _) PATTERN |