Class: RuboCop::Cop::RSpec::ContextMethod
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/rspec/context_method.rb
Overview
‘context` should not be used for specifying methods.
Constant Summary collapse
- MSG =
'Use `describe` for testing methods.'
Instance Method Summary collapse
- #context_method(node) ⇒ Object
-
#on_block(node) ⇒ Object
rubocop:disable InternalAffairs/NumblockHandler.
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
#context_method(node) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/rubocop/cop/rspec/context_method.rb', line 33 def_node_matcher :context_method, <<~PATTERN (block (send #rspec? :context ${(str #method_name?) (dstr (str #method_name?) ...)} ...) ...) PATTERN |
#on_block(node) ⇒ Object
rubocop:disable InternalAffairs/NumblockHandler
41 42 43 44 45 46 47 |
# File 'lib/rubocop/cop/rspec/context_method.rb', line 41 def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler context_method(node) do |context| add_offense(context) do |corrector| corrector.replace(node.send_node.loc.selector, 'describe') end end end |