From 9b4bd10cdb19eb62ee99baa0006119a670f45d07 Mon Sep 17 00:00:00 2001 From: Klaas Jan Wierenga Date: Thu, 2 May 2013 12:37:06 +0200 Subject: [PATCH] Use pipe factory method to handle 1.8 incompatible signature for IO.pipe. --- spec/spec_helper.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 70536cd..b9f3efe 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -21,6 +21,10 @@ def mock_error(subject, message) end end +def make_pipe + IO.method(:pipe).arity.zero? ? IO.pipe : IO.pipe("BINARY") +end + def foreman(args) capture_stdout do begin @@ -31,14 +35,14 @@ def foreman(args) end def forked_foreman(args) - rd, wr = IO.pipe("BINARY") + rd, wr = make_pipe Process.spawn("bundle exec bin/foreman #{args}", :out => wr, :err => wr) wr.close rd.read end def fork_and_capture(&blk) - rd, wr = IO.pipe("BINARY") + rd, wr = make_pipe pid = fork do rd.close wr.sync = true @@ -141,7 +145,7 @@ end def capture_stdout old_stdout = $stdout.dup - rd, wr = IO.method(:pipe).arity.zero? ? IO.pipe : IO.pipe("BINARY") + rd, wr = make_pipe $stdout = wr yield wr.close