A better approach could be to use a Logger instead of puts. If you choose to log to a file, then your problem is already solved! And, if you insist on logging to stdout, then you could simply increase the log level when running the tests - so long as you have a convenient way to set this log level. Something like: