Wednesday, 12 December 2007

Here's the story. Rake is a ruby-based DSL for building tasks. It's heavily used by Ruby on Rails, especially for database maintenance and testing. One of its use for testing is a use for testing _plugins_. The way rails does it is, well... let's say brings a few surprises.To run the tests of all plugins you enter command rake test:plugins, to run the test of a single plugin you provide an environment viariable using this syntax rake test:plugins PLUGIN=plugin_name. Now, to write a rake task that runs a subset of tests, and does some additional job, you'd set the variable from within your code and programatically invoke the test task.And this is what's not working. The problem is - all test tasks are evaluated before reading your file, and stored as a data. The particular task for running plugins simply generates all paths and stores it all in a huge hash (dictionary). After finding this out, all I was left to do was to copy rails' inner solution into my code. I don't like it much, though...