title: What is the best way to test interface of a command line application with Ruby?
body: <p>Say that I have simple command line application, that looks something like this</p>
  
  <pre><code># solution.rb
  
  puts "Enter your password:"
  password = gets
  
  if password == "secret"
    puts "you're logged in"
  else
    puts "wrong password"
  end
  </code></pre>
  
  <p>and I need to create a script, that will test if it works correctly. I don't want to test the code itself, only it's user interface.</p>
  
  <p>It would be a kind of homework checker, where a user can submit a script which is supposed to handle a certain task in a certain way, and this script will test it with given inputs.</p>
  
  <p>The idea is, that I would run something like</p>
  
  <pre><code>ruby tester.rb solution.rb
  </code></pre>
  
  <p>and the <code>tester.rb</code> would first run it and pass <code>secret</code> and check if it got <code>you're logged in</code> as a response, and the same thing for the second case.</p>
  
  <p>What would be the best way to achieve this?</p>