Class: MarkdownExec::TestHashDelegator::TestHashDelegatorHandleStream
- Inherits:
-
Minitest::Test
- Object
- Minitest::Test
- MarkdownExec::TestHashDelegator::TestHashDelegatorHandleStream
- Defined in:
- lib/hash_delegator.rb
Overview
require ‘stringio’
Instance Method Summary collapse
Instance Method Details
#setup ⇒ Object
3028 3029 3030 3031 3032 3033 3034 |
# File 'lib/hash_delegator.rb', line 3028 def setup @hd = HashDelegator.new @hd.instance_variable_set(:@run_state, OpenStruct.new(files: { stdout: [] })) @hd.instance_variable_set(:@delegate_object, { output_stdout: true }) end |
#test_handle_stream ⇒ Object
3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 |
# File 'lib/hash_delegator.rb', line 3036 def test_handle_stream stream = StringIO.new("line 1\nline 2\n") file_type = :stdout 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[:stdout] end |
#test_handle_stream_with_io_error ⇒ Object
3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 |
# File 'lib/hash_delegator.rb', line 3048 def test_handle_stream_with_io_error stream = StringIO.new("line 1\nline 2\n") file_type = :stdout 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[:stdout] end |