Module: ActiveSupport::Testing::Stream
Do not use. This module is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | activesupport/lib/active_support/testing/stream.rb |
Instance Method Summary
- #capture(stream) private
- #quietly(&block) private
- #silence_stream(stream) private
Instance Method Details
#capture(stream) (private)
[ GitHub ]# File 'activesupport/lib/active_support/testing/stream.rb', line 23
def capture(stream) stream = stream.to_s captured_stream = Tempfile.new(stream) stream_io = eval("$#{stream}", binding, __FILE__, __LINE__) origin_stream = stream_io.dup stream_io.reopen(captured_stream) yield stream_io.rewind captured_stream.read ensure captured_stream.close captured_stream.unlink stream_io.reopen(origin_stream) end
#quietly(&block) (private)
[ GitHub ]# File 'activesupport/lib/active_support/testing/stream.rb', line 17
def quietly(&block) silence_stream(STDOUT) do silence_stream(STDERR, &block) end end
#silence_stream(stream) (private)
[ GitHub ]# File 'activesupport/lib/active_support/testing/stream.rb', line 7
def silence_stream(stream) old_stream = stream.dup stream.reopen(IO::NULL) stream.sync = true yield ensure stream.reopen(old_stream) old_stream.close end