Class: RuboCop::RSpec::ExampleGroup
- Defined in:
- lib/rubocop/rspec/example_group.rb
Overview
Wrapper for RSpec example groups
Instance Method Summary collapse
- #examples ⇒ Object
- #hooks ⇒ Object
- #lets ⇒ Object
-
#scope_change?(node) ⇒ Object
Detect if the node is an example group or shared example.
- #subjects ⇒ Object
Methods inherited from Concept
#eql?, #hash, #initialize, #to_node
Methods included from Language::NodePattern
Methods included from Language
#example?, #example_group?, #example_group_with_body?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Constructor Details
This class inherits a constructor from RuboCop::RSpec::Concept
Instance Method Details
#examples ⇒ Object
30 31 32 33 34 |
# File 'lib/rubocop/rspec/example_group.rb', line 30 def examples find_all_in_scope(node, :example?).map do |node| Example.new(node) end end |
#hooks ⇒ Object
36 37 38 39 40 |
# File 'lib/rubocop/rspec/example_group.rb', line 36 def hooks find_all_in_scope(node, :hook?).map do |node| Hook.new(node) end end |
#lets ⇒ Object
22 23 24 |
# File 'lib/rubocop/rspec/example_group.rb', line 22 def lets find_all_in_scope(node, :let?) 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 16 17 18 19 20 |
# File 'lib/rubocop/rspec/example_group.rb', line 13 def_node_matcher :scope_change?, block_pattern(<<~PATTERN) { #SharedGroups.all #ExampleGroups.all #Includes.all } PATTERN |
#subjects ⇒ Object
26 27 28 |
# File 'lib/rubocop/rspec/example_group.rb', line 26 def subjects find_all_in_scope(node, :subject?) end |