This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.

Scripting an External Program
CodeExpectedActual
def run(command, input='')
  IO.popen(command, 'r+') do |io|
    io.puts input
    io.close_write
    return io.read
  end
end
run 'wc -w', 'How many words are in this string?'
"7\n" "7\n"
print 'Enter your password for sudo: '
sudo_password = gets.chomp
run('sudo apachectl graceful', user_password)
...
Enter your password for sudo: NoMethodError: private method `chomp' called for nil:NilClass
	from (irb):10
NameError: undefined local variable or method `user_password' for main:Object
	from (irb):11