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
Comments