Skip to content

Commit 31a5d51

Browse files
committed
Add spec helper for capturing stdout to a string
* Shout out to @avdi for his awesome RubyTapas! * http://www.rubytapas.com/episodes/29-Redirecting-Output
1 parent 3332d86 commit 31a5d51

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

spec/support/capture_stdout.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'stringio'
2+
3+
def capture_stdout
4+
captured_output = StringIO.new
5+
real_stdout = $stdout
6+
$stdout = captured_output
7+
yield
8+
ensure
9+
$stdout = real_stdout
10+
return captured_output.string
11+
end

0 commit comments

Comments
 (0)