Description: Fix race in tests.
Author: Alexander Gerasiov <gq@debian.org>
Last-Update: 2015-02-19
Forwarded: https://github.com/jpastuszek/capture-output/pull/1
Index: ruby-capture-output-1.0.0/spec/capture-output_spec.rb
===================================================================
--- ruby-capture-output-1.0.0.orig/spec/capture-output_spec.rb	2015-02-19 02:02:10.000000000 +0300
+++ ruby-capture-output-1.0.0/spec/capture-output_spec.rb	2015-02-19 02:27:48.107669177 +0300
@@ -3,14 +3,16 @@
 describe Capture do
   it "#stdout should capture all STDOUT IO content" do
 		Capture.stdout do
-			Process.spawn('echo "hello world"')
+			pid = Process.spawn('echo "hello world"')
+			Process.wait pid
 			STDOUT.puts 'puts'
 		end.should == "hello world\nputs\n"
   end
 
   it "#stderr should capture all STDERR IO content" do
 		Capture.stderr do
-			Process.spawn('echo "hello world" 1>&2')
+			pid = Process.spawn('echo "hello world" 1>&2')
+			Process.wait pid
 			STDERR.puts 'puts'
 		end.should == "hello world\nputs\n"
   end
@@ -18,8 +20,10 @@
 	it "#stdout and #stderr in combination" do
 		Capture.stdout do
 			Capture.stderr do
-				Process.spawn('echo "hello world out"')
-				Process.spawn('echo "hello world err" 1>&2')
+				pid = Process.spawn('echo "hello world out"')
+				Process.wait pid
+				pid = Process.spawn('echo "hello world err" 1>&2')
+				Process.wait pid
 			end.should == "hello world err\n"
 		end.should == "hello world out\n"
 	end
