Sha256: 6fcc53dd08ee41b4b5c9f582fc7c56c4001ccdd1d847481a765c15a33c7c0599
Contents?: true
Size: 1.27 KB
Versions: 9
Compression:
Stored size: 1.27 KB
Contents
require 'spec_helper' context 'when executed process had exited before read stdout and stderr,' do let(:backend) { Specinfra::Backend::Exec.new } it 'can consume stdout and stderr from buffer' do allow(IO).to receive(:select).and_wrap_original { |m, *args| sleep 1; m.call(*args) } result = backend.run_command("ruby -e 'STDOUT.puts \"stdout\"; STDERR.puts \"stderr\"'") expect(result.stdout.chomp).to eq('stdout') expect(result.stderr.chomp).to eq('stderr') end end context 'when executed process has exited between reading stdout and stderr,' do let(:backend) { Specinfra::Backend::Exec.new } it 'can consume stdout and stderr from buffer' do backend.stdout_handler = proc { |o| sleep 1 } result = backend.run_command("ruby -e 'STDOUT.puts \"stdout\"; STDOUT.close; STDERR.puts \"stderr\"'") expect(result.stdout.chomp).to eq('stdout') expect(result.stderr.chomp).to eq('stderr') end end context 'Output of stderr_handler' do let(:backend) { Specinfra::Backend::Exec.new } subject(:stderr) do allow(IO).to receive(:select).and_wrap_original { |m, *args| sleep 1; m.call(*args) } err = '' backend.stderr_handler = proc { |e| err += e } backend.run_command('echo foo 1>&2') err end it { expect(stderr).to eq "foo\n" } end
Version data entries
9 entries across 9 versions & 1 rubygems