class RuboCop::Cop::RSpec::SubjectStub


end
end
allow(bar).to receive(:qux?).and_return(true)
before do
subject(:bar) { baz }
describe Foo do
# bad
@example
@see github.com/rubocop-hq/rspec-style-guide#dont-stub-subject<br>@see samphippen.com/introducing-rspec-smells-and-where-to-find-them#smell-1-stubject<br>@see robots.thoughtbot.com/don-t-stub-the-system-under-test<br><br>Checks for stubbed test subjects.

def find_all_explicit_subjects(node)

def find_all_explicit_subjects(node)
  node.each_descendant(:block).with_object({}) do |child, h|
    name = subject(child)
    next unless name
    outer_example_group = child.each_ancestor.find do |a|
      example_group?(a)
    end
    h[outer_example_group] ||= []
    h[outer_example_group] << name
  end
end

def find_subject_expectations(node, subject_names = [], &block)

def find_subject_expectations(node, subject_names = [], &block)
  subject_names = @explicit_subjects[node] if @explicit_subjects[node]
  expectation_detected = (subject_names + [:subject]).any? do |name|
    message_expectation?(node, name)
  end
  return yield(node) if expectation_detected
  node.each_child_node do |child|
    find_subject_expectations(child, subject_names, &block)
  end
end

def on_top_level_group(node)

def on_top_level_group(node)
  @explicit_subjects = find_all_explicit_subjects(node)
  find_subject_expectations(node) do |stub|
    add_offense(stub)
  end
end