# File lib/rspec/support/spec/stderr_splitter.rb, line 6 def initialize(original) @orig_stderr = original @output_tracker = ::StringIO.new end
# File lib/rspec/support/spec/stderr_splitter.rb, line 21 def ==(other) @orig_stderr == other end
# File lib/rspec/support/spec/stderr_splitter.rb, line 34 def has_output? !output.empty? end
# 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
# File lib/rspec/support/spec/stderr_splitter.rb, line 47 def output @output_tracker.string end
# File lib/rspec/support/spec/stderr_splitter.rb, line 38 def reset! @output_tracker = ::StringIO.new end
# File lib/rspec/support/spec/stderr_splitter.rb, line 42 def verify_example!(example) example.send(:fail,"Warnings were generated: #{output}") if has_output? reset! end
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(line) if line !~ /^\S+gems\/ruby\-\S+:\d+: warning:/ @orig_stderr.write(line) @output_tracker.write(line) end end