def capturing_output
output = StringIO.new
$stdout = output
yield
output.string
ensure
$stdout = STDOUT
end
then…
it "exits immediately from --version" do
output = capturing_output do
lambda {
Erector.new(["--version"])
}.should raise_error(SystemExit)
end
output.should == Erector::VERSION + "n"
end
You grab that from the rake tests, as well? I was doing the [same thing for rake](http://www.timocracy.com/articles/2008/02/21/calling-invoking-rails-rake-tasks-from-within-ruby-for-testing-try-2) and that is where I found it.
May 13, 2009 at 4:12 pm
I prefer doing it with Open3: http://gist.github.com/100773
May 14, 2009 at 12:56 am
Use commander for executables :D https://visionmedia.github.com/commander
May 15, 2009 at 5:22 am