title: Running Ruby unit tests with Rake
body: <p>I was investigating using the Rake build tool to automate running unit tests. I searched the web, but all the examples were for using rails. I usually just write small command-line programs or simple Sinatra applications.</p>
  
  <p>So I came up with the following (probably bad) solution that just emulates what I would do on the command-line: (I just ran one unit test as an example.)</p>
  
  <pre><code>desc 'Run unit tests'
  task :test do
      sh 'ruby -I lib test/test_entry.rb'
  end
  task :default =&gt; :test
  </code></pre>
  
  <p>It works, but I can't help thinking there must be a better way, just writing <code>require 'test/test_entry.rb'</code> doesn't work. I get <code>require</code> problems, Ruby can't find the <code>lib</code> directory, where all the files are.</p>