Class: RuboCop::RSpec::ExampleGroup

Inherits:
Concept
  • Object
show all
Defined in:
lib/rubocop/rspec/example_group.rb

Overview

Wrapper for RSpec example groups

Constant Summary

Constants included from Language

Language::ALL

Instance Method Summary collapse

Methods inherited from Concept

#eql?, #hash, #initialize, #to_node

Constructor Details

This class inherits a constructor from RuboCop::RSpec::Concept

Instance Method Details

#examplesObject



30
31
32
# File 'lib/rubocop/rspec/example_group.rb', line 30

def examples
  examples_in_scope(node).map(&Example.public_method(:new))
end

#hook(node) ⇒ Object

Detect if node is ‘before`, `after`, `around`



20
21
22
# File 'lib/rubocop/rspec/example_group.rb', line 20

def_node_matcher :hook, <<-PATTERN
  (block {$(send nil? #{Hooks::ALL.node_pattern_union} ...)} ...)
PATTERN

#hooksObject



34
35
36
# File 'lib/rubocop/rspec/example_group.rb', line 34

def hooks
  hooks_in_scope(node).map(&Hook.public_method(:new))
end

#scope_change?(node) ⇒ Object

Detect if the node is an example group or shared example

Selectors which indicate that we should stop searching



13
14
15
# File 'lib/rubocop/rspec/example_group.rb', line 13

def_node_matcher :scope_change?, (
  ExampleGroups::ALL + SharedGroups::ALL + Includes::ALL
).block_pattern

#subjectsObject



26
27
28
# File 'lib/rubocop/rspec/example_group.rb', line 26

def subjects
  subjects_in_scope(node)
end