diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-08-26 12:28:34 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-08-26 12:28:34 -0700 |
commit | ef897f804c57ffde6206daa0625f3d10fa9fbfed (patch) | |
tree | 0bbe7836e5b1852f0074d69df063472f4dc6cf69 | |
parent | 4111356d7692bd303db4a7382dbc05a0b824db9f (diff) | |
parent | 710da8c05f5c39c75864a918fb9cf159bba174c1 (diff) | |
download | mixlib-shellout-ef897f804c57ffde6206daa0625f3d10fa9fbfed.tar.gz |
Merge pull request #103 from chef/jdm/test
Don't use presence of fd to check if fd's were inherited
-rw-r--r-- | spec/mixlib/shellout_spec.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb index 337512f..1c5ce31 100644 --- a/spec/mixlib/shellout_spec.rb +++ b/spec/mixlib/shellout_spec.rb @@ -1064,16 +1064,28 @@ describe Mixlib::ShellOut do context 'with open files for parent process' do before do @test_file = Tempfile.new('fd_test') + @test_file.write("hello") + @test_file.flush end after do @test_file.close if @test_file end - let(:ruby_code) { "fd = File.for_fd(#{@test_file.to_i}) rescue nil; puts fd.nil?" } + let(:ruby_code) { "fd = File.for_fd(#{@test_file.to_i}) rescue nil; if fd; fd.seek(0); puts fd.read(5); end" } it "should not see file descriptors of the parent" do - expect(stdout.chomp).to eql("true") + # The reason this test goes through the effor of writing out + # a file and checking the contents along side the presence of + # a file descriptor is because on Windows, we're seeing that + # a there is a file descriptor present, but it's not the same + # file. That means that if we just check for the presence of + # a file descriptor, the test would fail as that slot would + # have something. + # + # See https://github.com/chef/mixlib-shellout/pull/103 + # + expect(stdout.chomp).not_to eql("hello") end end |