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
3142 3143 3144 3145 3146 3147 3148 |
# File 'lib/hash_delegator.rb', line 3142 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
3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 |
# File 'lib/hash_delegator.rb', line 3150 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
3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 |
# File 'lib/hash_delegator.rb', line 3162 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 |