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
2930 2931 2932 2933 2934 2935 2936 |
# File 'lib/hash_delegator.rb', line 2930 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
2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 |
# File 'lib/hash_delegator.rb', line 2938 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
2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 |
# File 'lib/hash_delegator.rb', line 2950 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 |