Class: MarkdownExec::TestHashDelegatorHandleStream
- Defined in:
- lib/hash_delegator.rb
Overview
require ‘stringio’
Instance Method Summary collapse
Instance Method Details
#setup ⇒ Object
6842 6843 6844 6845 6846 |
# File 'lib/hash_delegator.rb', line 6842 def setup @hd = HashDelegator.new(output_stdout: true) @hd.instance_variable_set(:@run_state, OpenStruct.new(files: StreamsOut.new)) end |
#test_handle_stream ⇒ Object
6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 |
# File 'lib/hash_delegator.rb', line 6848 def test_handle_stream stream = StringIO.new("line 1\nline 2\n") file_type = ExecutionStreams::STD_OUT Thread.new { @hd.handle_stream(stream: stream, file_type: file_type) } @hd.wait_for_stream_processing assert_equal ["line 1\n", "line 2\n"], @hd.instance_variable_get(:@run_state) .files.stream_lines(ExecutionStreams::STD_OUT) end |
#test_handle_stream_with_io_error ⇒ Object
6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 |
# File 'lib/hash_delegator.rb', line 6860 def test_handle_stream_with_io_error stream = StringIO.new("line 1\nline 2\n") file_type = ExecutionStreams::STD_OUT stream.stubs(:each_line).raises(IOError) Thread.new { @hd.handle_stream(stream: stream, file_type: file_type) } @hd.wait_for_stream_processing assert_equal [], @hd.instance_variable_get(:@run_state) .files.stream_lines(ExecutionStreams::STD_OUT) end |