Written by Sean Behan on Thu Aug 22nd 2013

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 with..
#Sinatra #Rake #Testing

Just finishing up brewing up some fresh ground comments...