class RSpec::Support::StdErrSplitter

Public Class Methods

new(original) click to toggle source
# File lib/rspec/support/spec/stderr_splitter.rb, line 6
def initialize(original)
  @orig_stderr    = original
  @output_tracker = ::StringIO.new
end

Public Instance Methods

==(other) click to toggle source
# File lib/rspec/support/spec/stderr_splitter.rb, line 21
def ==(other)
  @orig_stderr == other
end
has_output?() click to toggle source
# File lib/rspec/support/spec/stderr_splitter.rb, line 32
def has_output?
  !output.empty?
end
method_missing(name, *args, &block) click to toggle source
# File lib/rspec/support/spec/stderr_splitter.rb, line 16
def method_missing(name, *args, &block)
  @output_tracker.__send__(name, *args, &block)
  @orig_stderr.__send__(name, *args, &block)
end
output() click to toggle source
# File lib/rspec/support/spec/stderr_splitter.rb, line 45
def output
  @output_tracker.string
end
reset!() click to toggle source
# File lib/rspec/support/spec/stderr_splitter.rb, line 36
def reset!
  @output_tracker = ::StringIO.new
end
verify_example!(example) click to toggle source
# File lib/rspec/support/spec/stderr_splitter.rb, line 40
def verify_example!(example)
  example.send(:fail,"Warnings were generated: #{output}") if has_output?
  reset!
end
write(*args) click to toggle source

To work around JRuby error: TypeError: $stderr must have write method, RSpec::StdErrSplitter given

# File lib/rspec/support/spec/stderr_splitter.rb, line 27
def write(*args)
  @orig_stderr.write(*args)
  @output_tracker.write(*args)
end