forked from bsmth/orgbots
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tcob
committed
Apr 15, 2018
1 parent
3ade6bf
commit 1f0e655
Showing
8 changed files
with
49 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Temporarily redirects STDOUT and STDERR to /dev/null | ||
# but does print exceptions should there occur any. | ||
# Call as: | ||
# suppress_output { puts 'never printed' } | ||
# | ||
def suppress_output | ||
begin | ||
original_stderr = $stderr.clone | ||
original_stdout = $stdout.clone | ||
$stderr.reopen(File.new('/dev/null', 'w')) | ||
$stdout.reopen(File.new('/dev/null', 'w')) | ||
retval = yield | ||
rescue Exception => e | ||
$stdout.reopen(original_stdout) | ||
$stderr.reopen(original_stderr) | ||
raise e | ||
ensure | ||
$stdout.reopen(original_stdout) | ||
$stderr.reopen(original_stderr) | ||
end | ||
retval | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
require 'test/unit' | ||
require_relative 'suppress_output' | ||
require_relative '../lib/utils/reporter' | ||
|
||
class TestReporter < Test::Unit::TestCase | ||
def test_welcome | ||
rep = Reporter.new | ||
assert_nothing_raised do | ||
rep.welcome | ||
suppress_output { rep.welcome } | ||
end | ||
end | ||
end |