class RSpec::Support::StdErrSplitter

def ==(other)

def ==(other)
  @orig_stderr == other
end

def has_output?

def has_output?
  !output.empty?
end

def initialize(original)

def initialize(original)
  @orig_stderr    = original
  @output_tracker = ::StringIO.new
  @last_line = nil
end

def method_missing(name, *args, &block)

def method_missing(name, *args, &block)
  @output_tracker.__send__(name, *args, &block) if @output_tracker.respond_to?(name)
  @orig_stderr.__send__(name, *args, &block)
end

def output

def output
  @output_tracker.string
end

def reopen(*args)

def reopen(*args)
  reset!
  @orig_stderr.reopen(*args)
end

def reset!

def reset!
  @output_tracker = ::StringIO.new
end

def to_io

can't convert RSpec::Support::StdErrSplitter into String
To work around JRuby error:
def to_io
  @orig_stderr.to_io
end

def verify_no_warnings!

def verify_no_warnings!
  raise "Warnings were generated: #{output}" if has_output?
  reset!
end

def write(line)

TypeError: $stderr must have write method, RSpec::StdErrSplitter given
To work around JRuby error:
def write(line)
  return if line =~ %r{^\S+/gems/\S+:\d+: warning:} # http://rubular.com/r/kqeUIZOfPG
  # Ruby 2.7.0 warnings from keyword arguments span multiple lines, extend check above
  # to look for the next line.
  return if @last_line =~ %r{^\S+/gems/\S+:\d+: warning:} &&
            line =~ %r{warning: The called method .* is defined here}
  # Ruby 2.7.0 complains about hashes used in place of keyword arguments
  # Aruba 0.14.2 uses this internally triggering that here
  return if line =~ %r{lib/ruby/2\.7\.0/fileutils\.rb:622: warning:}
  @orig_stderr.write(line)
  @output_tracker.write(line)
ensure
  @last_line = line
end