Class: RuboCop::Cop::RSpec::ClassCheck
- Extended by:
- AutoCorrector
- Includes:
- ConfigurableEnforcedStyle
- Defined in:
- lib/rubocop/cop/rspec/class_check.rb
Overview
Enforces consistent use of ‘be_a` or `be_kind_of`.
Constant Summary collapse
- MSG =
'Prefer `%<preferred>s` over `%<current>s`.'
- METHOD_NAMES_FOR_BE_A =
::Set[ :be_a, :be_an ].freeze
- METHOD_NAMES_FOR_KIND_OF =
::Set[ :be_a_kind_of, :be_kind_of ].freeze
- PREFERRED_METHOD_NAME_BY_STYLE =
{ be_a: :be_a, be_kind_of: :be_kind_of }.freeze
- RESTRICT_ON_SEND =
%i[ be_a be_a_kind_of be_an be_kind_of ].freeze
Instance Method Summary collapse
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#on_send(node) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rubocop/cop/rspec/class_check.rb', line 54 def on_send(node) return unless offending?(node) add_offense( node.loc.selector, message: (node) ) do |corrector| autocorrect(corrector, node) end end |