class RuboCop::Cop::RSpec::ExpectOutput
def inside_example_scope?(node)
within a `before(:all)` or otherwise outside of an example
an expectation. Therefore, assignments to stderr or stdout
we only care about situations where you would replace with
We want to encourage using `expect { ... }.to output` so
Detect if we are inside the scope of a single example
def inside_example_scope?(node) return false if node.nil? || example_group?(node) return true if example?(node) return RuboCop::RSpec::Hook.new(node).example? if hook?(node) inside_example_scope?(node.parent) end