-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean up spec helpers, no top level methods please
- Loading branch information
Showing
2 changed files
with
11 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,12 @@ | ||
def capture_stderr(&block) | ||
original_stderr = $stderr | ||
$stderr = fake = StringIO.new | ||
begin | ||
yield | ||
ensure | ||
$stderr = original_stderr | ||
end | ||
fake.string | ||
end | ||
|
||
def capture_stdout(&block) | ||
original_stdout = $stdout | ||
$stdout = fake = StringIO.new | ||
begin | ||
yield | ||
ensure | ||
$stdout = original_stdout | ||
end | ||
fake.string | ||
end | ||
|
||
# wrapper around raise_error that captures stderr | ||
def should_abort_with(msg) | ||
capture_stderr do | ||
expect do | ||
module OutputStreams | ||
def capture_stdout(&block) | ||
original_stdout = $stdout | ||
$stdout = fake = StringIO.new | ||
begin | ||
yield | ||
end.to raise_error SystemExit, msg | ||
ensure | ||
$stdout = original_stdout | ||
end | ||
fake.string | ||
end | ||
end |