Created
February 9, 2012 05:00
-
-
Save mgreenly/1777441 to your computer and use it in GitHub Desktop.
sinking stdout in rspec
This file contains hidden or 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
| class Foo | |
| def run | |
| puts "usage: foo" | |
| 0 | |
| end | |
| end | |
| RSpec.configure do |config| | |
| config.before(:all) do | |
| @null_out = File.open('/dev/null', 'w') | |
| @orig_out = $stdout | |
| end | |
| config.before(:each) do | |
| $stdout = @null_out | |
| end | |
| config.after(:each) do | |
| $stdout = @orig_out | |
| end | |
| end | |
| describe Foo do | |
| it { subject.run.should eq(0) } | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment