From a61f3b514a64655ac625d334705df68d87bb424e Mon Sep 17 00:00:00 2001 From: Aleksey Strizhak Date: Wed, 14 Nov 2018 13:54:12 +0500 Subject: [PATCH] supress console output during rspec tests --- spec/spec_helper.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a0930085..f35cf55d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,4 +6,15 @@ c.include Helpers c.color = true c.formatter = :documentation if ENV["USE_REPORTERS"] + original_stderr = $stderr + original_stdout = $stdout + c.before(:all) do + # Redirect stderr and stdout + $stderr = File.open(File::NULL, "w") + $stdout = File.open(File::NULL, "w") + end + c.after(:all) do + $stderr = original_stderr + $stdout = original_stdout + end end