Skip to content

Instantly share code, notes, and snippets.

@EricLondon
Created February 19, 2019 20:25
Show Gist options
  • Save EricLondon/2cb0e2478e379aa70fef3e1e14e49620 to your computer and use it in GitHub Desktop.
Save EricLondon/2cb0e2478e379aa70fef3e1e14e49620 to your computer and use it in GitHub Desktop.
RSpec helper capture stdout
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