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
3084 3085 3086 3087 3088 3089 3090 |
# File 'lib/hash_delegator.rb', line 3084 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
3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 |
# File 'lib/hash_delegator.rb', line 3092 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
3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 |
# File 'lib/hash_delegator.rb', line 3104 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 |