Created
February 19, 2019 20:25
-
-
Save EricLondon/2cb0e2478e379aa70fef3e1e14e49620 to your computer and use it in GitHub Desktop.
RSpec helper capture stdout
This file contains hidden or 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
module Helpers | |
def with_captured_stdout | |
original_stdout = $stdout | |
$stdout = StringIO.new | |
yield | |
$stdout.string | |
ensure | |
$stdout = original_stdout | |
end | |
end | |
__END__ | |
RSpec.configure do |config| | |
config.include Helpers | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment