/usr/lib/ruby/vendor_ruby/rspec/support/spec/stderr_splitter.rb is in ruby-rspec-support 3.5.0c3e0m0s0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | require 'stringio'
module RSpec
module Support
class StdErrSplitter
def initialize(original)
@orig_stderr = original
@output_tracker = ::StringIO.new
end
respond_to_name = (::RUBY_VERSION.to_f < 1.9) ? :respond_to? : :respond_to_missing?
define_method respond_to_name do |*args|
@orig_stderr.respond_to?(*args) || super(*args)
end
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 ==(other)
@orig_stderr == other
end
def reopen(*args)
reset!
@orig_stderr.reopen(*args)
end
# To work around JRuby error:
# can't convert RSpec::Support::StdErrSplitter into String
def to_io
@orig_stderr.to_io
end
# To work around JRuby error:
# TypeError: $stderr must have write method, RSpec::StdErrSplitter given
def write(line)
return if line =~ %r{^\S+/gems/\S+:\d+: warning:} # http://rubular.com/r/kqeUIZOfPG
@orig_stderr.write(line)
@output_tracker.write(line)
end
def has_output?
!output.empty?
end
def reset!
@output_tracker = ::StringIO.new
end
def verify_no_warnings!
raise "Warnings were generated: #{output}" if has_output?
reset!
end
def output
@output_tracker.string
end
end
end
end
|