Module: RuboCop::Cop::Thoughtbot::SpecGroup

Extended by:
AST::NodePattern::Macros
Included in:
NoBefore, NoLet
Defined in:
lib/rubocop/cop/thoughtbot/mixin/spec_group.rb

Overview

Common functionality for cops that flag a bare RSpec DSL call.

A spec directory holds more than specs. A fake Sinatra or Grape app under spec/support defines a before of its own, so a cop that matches on the method name alone flags code that has nothing to do with RSpec. Asking where the call sits keeps the cop to RSpec's DSL.

Constant Summary collapse

SCOPES =
%i[block numblock itblock class module].freeze
SPEC_GROUPS =

Matches rubocop-rspec's ExampleGroups and SharedGroups.

%i[
  describe context feature example_group
  xdescribe xcontext xfeature
  fdescribe fcontext ffeature
  shared_examples shared_examples_for shared_context
].freeze

Instance Method Summary collapse

Instance Method Details

#extends_shared_context?(node) ⇒ Object



32
33
34
# File 'lib/rubocop/cop/thoughtbot/mixin/spec_group.rb', line 32

def_node_matcher :extends_shared_context?, <<~PATTERN
  (send nil? :extend (const (const {nil? cbase} :RSpec) :SharedContext))
PATTERN

#spec_group?(node) ⇒ Object



26
27
28
29
# File 'lib/rubocop/cop/thoughtbot/mixin/spec_group.rb', line 26

def_node_matcher :spec_group?, <<~PATTERN
  (any_block
    (send {nil? (const {nil? cbase} :RSpec)} #spec_group_name? ...) ...)
PATTERN