Class: MarkdownExec::TestHashDelegatorHandleStream
- Defined in:
- lib/hash_delegator.rb
Overview
require ‘stringio’
Instance Method Summary collapse
Instance Method Details
#setup ⇒ Object
4901 4902 4903 4904 4905 4906 4907 |
# File 'lib/hash_delegator.rb', line 4901 def setup @hd = HashDelegator.new @hd.instance_variable_set(:@run_state, OpenStruct.new(files: StreamsOut.new)) @hd.instance_variable_set(:@delegate_object, { output_stdout: true }) end |
#test_handle_stream ⇒ Object
4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 |
# File 'lib/hash_delegator.rb', line 4909 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', 'line 2'], @hd.instance_variable_get(:@run_state) .files.stream_lines(ExecutionStreams::STD_OUT) end |
#test_handle_stream_with_io_error ⇒ Object
4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 |
# File 'lib/hash_delegator.rb', line 4921 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 |