summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHo-Sheng Hsiao <hosheng.hsiao@gmail.com>2012-03-23 17:16:16 -0400
committerHo-Sheng Hsiao <hosheng.hsiao@gmail.com>2012-03-23 17:16:16 -0400
commit850266cd5ac874e8ce2e9d0cf3a02da9ece0bf57 (patch)
tree960a8ee48a9388b03cc44618233e63cfc1046654 /spec
parentf8ca764ddced3eac6f0bdafdf429437eb8fa9819 (diff)
downloadmixlib-shellout-850266cd5ac874e8ce2e9d0cf3a02da9ece0bf57.tar.gz
[RSPEC] Refactored spec for closing stdin when we have no input data for it
Diffstat (limited to 'spec')
-rw-r--r--spec/mixlib/shellout/shellout_spec.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/spec/mixlib/shellout/shellout_spec.rb b/spec/mixlib/shellout/shellout_spec.rb
index 957ebf3..7a3e633 100644
--- a/spec/mixlib/shellout/shellout_spec.rb
+++ b/spec/mixlib/shellout/shellout_spec.rb
@@ -682,10 +682,17 @@ describe Mixlib::ShellOut do
end
end
- it "closes stdin on the child process so it knows not to wait for any input" do
- cmd = Mixlib::ShellOut.new(%q{ruby -e 'print STDIN.eof?.to_s'})
- cmd.run_command
- cmd.stdout.should == "true"
+ context 'without input data' do
+ context 'with subprocess that expects stdin' do
+ let(:ruby_code) { %q{print STDIN.eof?.to_s} }
+ let(:cmd) { ruby_eval.call(ruby_code) }
+
+ # If we don't have anything to send to the subprocess, we need to close
+ # stdin so that the subprocess won't wait for input.
+ it 'should close stdin' do
+ stdout.should eql("true")
+ end
+ end
end
it "doesn't hang when STDOUT is closed before STDERR" do