Skip to content

Commit 2a22dbd

Browse files
committed
Fix intermittent test failures (#21)
* Be specific about which write causes an exception * Wait a little longer for the pipe to finish closing after a writer exception
1 parent e3afaa3 commit 2a22dbd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

spec/process_executer/monitored_pipe_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,34 +135,34 @@
135135
context 'when a writer raises an exception' do
136136
let(:output) { double('output') }
137137
before do
138-
expect(output).to receive(:write).with(String).and_raise(
138+
expect(output).to receive(:write).with('hello').and_raise(
139139
Encoding::UndefinedConversionError, 'UTF-8 conversion error'
140140
)
141141
end
142142
let(:writers) { [output] }
143143

144-
it 'should kill the monitoring thread' do
144+
it 'should eventually kill the monitoring thread' do
145145
monitored_pipe.write('hello')
146-
sleep(0.02)
146+
sleep(0.1)
147147
expect(monitored_pipe.thread.alive?).to eq(false)
148148
end
149149

150-
it 'should set the state to :closed' do
150+
it 'should eventually set the state to :closed' do
151151
monitored_pipe.write('hello')
152-
sleep(0.02)
152+
sleep(0.1)
153153
expect(monitored_pipe.state).to eq(:closed)
154154
end
155155

156-
it 'should save the exception raised to #exception' do
156+
it 'should eventually save the exception raised to #exception' do
157157
monitored_pipe.write('hello')
158-
sleep(0.02)
158+
sleep(0.1)
159159
expect(monitored_pipe.exception).to be_a(Encoding::UndefinedConversionError)
160160
expect(monitored_pipe.exception.message).to eq('UTF-8 conversion error')
161161
end
162162

163163
it 'should raise an exception if #write is called after the pipe is closed' do
164164
monitored_pipe.write('hello')
165-
sleep(0.02)
165+
sleep(0.1)
166166
expect { monitored_pipe.write('world') }.to raise_error(IOError, 'closed stream')
167167
end
168168
end

0 commit comments

Comments
 (0)