class RuboCop::RSpec::ExampleGroup

Wrapper for RSpec example groups

def examples

def examples
  find_all_in_scope(node, :example?).map(&Example.public_method(:new))
end

def find_all(node, predicate)

def find_all(node, predicate)
  if public_send(predicate, node)
    [node]
  elsif scope_change?(node) || example?(node)
    []
  else
    find_all_in_scope(node, predicate)
  end
end

def find_all_in_scope(node, predicate)

Returns:
  • (Array) - discovered nodes

Parameters:
  • node (RuboCop::Node) -- node to recursively search
def find_all_in_scope(node, predicate)
  node.each_child_node.flat_map do |child|
    find_all(child, predicate)
  end
end

def hooks

def hooks
  find_all_in_scope(node, :hook?).map(&Hook.public_method(:new))
end

def lets

def lets
  find_all_in_scope(node, :let?)
end

def subjects

def subjects
  find_all_in_scope(node, :subject?)
end