summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHo-Sheng Hsiao <hosheng.hsiao@gmail.com>2012-03-23 12:29:34 -0400
committerHo-Sheng Hsiao <hosheng.hsiao@gmail.com>2012-03-23 12:29:34 -0400
commitfe51d5cad3eb6421b9d645a78afb6f53a03b3cd6 (patch)
treec3fa28c9d9fc26a12430acf495ad108b7c9e097a /spec
parentb11d43ff05bb8ec7fe22e22bd1b2681cb637fcb3 (diff)
downloadmixlib-shellout-fe51d5cad3eb6421b9d645a78afb6f53a03b3cd6.tar.gz
[RSPEC] Refactored spec for subprocess that closes one pipe and continues writing in the other
Diffstat (limited to 'spec')
-rw-r--r--spec/mixlib/shellout/shellout_spec.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/spec/mixlib/shellout/shellout_spec.rb b/spec/mixlib/shellout/shellout_spec.rb
index 3df6291..4f587ad 100644
--- a/spec/mixlib/shellout/shellout_spec.rb
+++ b/spec/mixlib/shellout/shellout_spec.rb
@@ -573,11 +573,22 @@ describe Mixlib::ShellOut do
end
end
- it "doesn't hang or lose output when a process closes one of stdout/stderr and continues writing to the other" do
- halfandhalf = %q{ruby -e 'STDOUT.close;sleep 0.5;STDERR.puts :win'}
- cmd = Mixlib::ShellOut.new(halfandhalf)
- cmd.run_command
- cmd.stderr.should == "win#{LINE_ENDING}"
+ context 'with subprocess that closes stdout and continues writing to stderr' do
+ let(:half_and_half) { "STDOUT.close; sleep 0.5; STDERR.puts :win" }
+ let(:cmd) { ruby_eval.call(half_and_half) }
+
+ it 'should not hang or lose outupt' do
+ stderr.should eql("win#{LINE_ENDING}")
+ end
+ end
+
+ context 'with subprocess that closes stderr and continues writing to stdout' do
+ let(:half_and_half) { "STDERR.close; sleep 0.5; STDOUT.puts :win" }
+ let(:cmd) { ruby_eval.call(half_and_half) }
+
+ it 'should not hang or lose outupt' do
+ stdout.should eql("win#{LINE_ENDING}")
+ end
end
it "does not deadlock when the subprocess writes lots of data to both stdout and stderr" do