Best way to snapshot test STDOUT? #36
Unanswered
spenserblack
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm a beginner to Ruby, so I don't know the best way to do this. What would be the best way to make a snapshot test for a method that would typically output to STDOUT (in my case,
MyGem::CLI.start
)?Would it also be reasonable for this to be a feature request? RSpec has
.output(/pattern/).to_stdout
(and.to_stderr
), so would it be reasonable (or possible) to support something like this?Edit: I'm reassigning
$stdout
to aStringIO
instance, but I'm wondering if this should be built-in.Beta Was this translation helpful? Give feedback.
All reactions