How To Use Rake to Run Your Test Suite with Sinatra

       

If you're using Sinatra and you want to use rake to run your test suite, you will need to create a Rakefile and put this in it.


require 'rake/testtask'

task :default do
  ENV['RACK_ENV'] = 'test'
  Rake::Task['test'].invoke
end

Rake::TestTask.new(:default) do |t|
  t.libs << "test"
  t.pattern = 'test/*_test.rb'
  t.verbose = true
end

This assumes your test suite is under the 'test/' directory and the files you want to test match the '_test.rb' pattern.

Now you can run rake from the command line and the default task (your test suite) will execute!


rake
Tagged w/ #sinatra #rake #testing

Apps I've Built

PhotoLocationChanger
Easily change the location on your photos and videos
Click here for more info about the app
PhotoDateChanger
Easily change the dates and times on your photos and videos
Click here for more info about the app
VocabReminder
English dictionary with notifications so you won't forget what you're studying!
Click here for more info about the app
VocabQuiz
The app that quizzes and scores you on your vocabulary!
Click here for more info about the app