ActiveRecord, , , , , " />

ar_test_runner: Run the ActiveRecord unit test suite with your modifications

May 12, 2009

Run ActiveRecord regression tests with your code loadedIf you write plugins or code to enhance ActiveRecord functionality, its a really good idea to run the ActiveRecord core test suite with your cool additions loaded. After working on ar-extensions, I liked the idea of running the core tests along with the plugin specific tests.  However, I soon grew tired of coding the same Rakefile for each of my eleventy billion AR plugins. Not DRY. Not fun. Not a unicorn party.

Thus was born, ar_test_runner, a convenient plugin with a rake task to run the ActiveRecord test suites with your  code/gem/plugin load. You even can choose the ActiveRecord version and database.

Install

  gem sources -a http://gems.github.com
  sudo gem install blythedunham-ar_test_runner

Run ar_test_runner

Run all plugins and lib files against sqlite for app version

ar_test_runner DB=sqlite

Test 2.2.2 with rails_devs_for_data_integrity plugin loaded on mysql

ar_test_runner PLUGIN=rails_devs_for_data_integrity AR_DIR=/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2

Rake Tasks

ar_test_runner works as a rake task, if installed as a plugin or by adding require “ar_test_runner” to the application’s Rakefile. The following example tests the applications default version of ActiveRecord with the files RAILS_ROOT/lib/my_file.rb and RAILS_ROOT/lib/my_other_file.rb loaded

rake test:activerecord:mysql FILE=lib/my_file.rb,lib/my_other_file.rb

Customize

To specify (or skip)  gems, files, dirs, and plugins ot load or build custom runs see the documentation at ar_test_runner .

Leave a Reply