Skip to content

Commit

Permalink
Silence stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
masutaka committed Aug 6, 2017
1 parent b6152a4 commit 66324a7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
RSpec.configure do |config|
config.include LoadFixtureHelper

config.before(:all) { silence_stdout }
config.after(:all){ enable_stdout }

# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
Expand Down Expand Up @@ -106,3 +109,15 @@
Kernel.srand config.seed
=end
end

# Redirects stdout to /dev/null.
def silence_stdout
@orig_stdout = $stdout
$stdout = File.new('/dev/null', 'w')
end

# Replace stdout so anything else is output correctly.
def enable_stdout
$stdout = @orig_stdout
@orig_stdout = nil
end

0 comments on commit 66324a7

Please sign in to comment.