Rails with Rake test_performance Task

In a bid to have more fun, I’m hacking my way through the later parts of Agile Web Development with Rails (1st Edition). I added in the admittedly simplistic performance test of adding 100 orders to the database. Just to be a bit anal I wanted to add a Rake task for it as well.

I’m still pretty much in squid/newbie mode with Rake, but by adding the following 4 lines of code to in lib/tasks/performance.rake I was able to successfully create a test_performance task:

desc "Run performance tests"
Rake::TestTask.new("test_performance") { |test|
  test.pattern = 'test/performance/*_test.rb'
}

Then a simple

1
rake test_performance

runs the performance tests.