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 and that is where I found it.
remove
I prefer doing it with Open3: http://gist.github.com/100773
remove
Use commander for executables :D https://visionmedia.github.com/commander
remove