Fakeout is an easy way of testing the output of your command line tools and libraries.
It catches all output to
$stderr while activated so you can test the correct output is given by your library or script. It also has the nice side-effect of keeping your test results from being crapped up with non test result text and data.
To load and activate Fakeout:
Manually Activate and Deactivate
If you want to control when Fakeout starts and stops capturing output:
Fakeout.activate! # your code Fakeout.deactivate!
Both of the approaches above work for RSpec, UnitTest, or whatever.
Fakeout::TestHelpers module into your spec or test class exposes two objects,
stderr, each containing any output sent, while Fakeout is activated, to
it "should rawr to $stdout" do lion.rawr_to_stdout stdout.should include "RAWR!!" end
Fakeout::SpecHelpers will automatically activate before each example and deactivate after each one when included. It can be included into individual Example Groups:
describe "Something" do include Fakeout::SpecHelpers end
or included into all Example Groups:
RSpec.config do |c| c.include Fakeout::SpecHelpers end
* Note that if you use
SpecHelpers with RSpec, you DO NOT need to include
class SomethingTest < Test::Unit::TestCase include Fakeout::TestHelpers
def setup Fakeout.activate! end
def teardown Fakeout.deactivate! end end
$ gem install fakeout
1. Fork Fakeout
2. Create a topic branch –
git checkout -b branch_name
3. Push branch to your fork –
git push origin branch_name
4. Send a pull request
Defunkt for FakeFS, which much of Fakeout is modeled after.