I''ve been going plugin crazy lately, so I needed a simple way to test
them. I created a simple plugin [1] that has a rake file,
database.yml, and a test helper. It provides tasks like
test_plugin_name to execute the tests in plugins/plugin_name/test,
with some assumptions on where fixtures and your schema are at.
rake test_blah # uses sqlite
rake test_blah DB=mysql
Since I used schema.rb, only migration-aware adapters are supported.
I could easily extend it to look for #{adapter}.sql files also.
I have another plugin using this scheme currently, Calculations. I
wrote this on the plane trip back from RubyConf. It allows you to do
aggregate queries like:
Order.calculate(:sum, :cost).group_by(:country).having { |value| value > 75 }
I''ll be adding convenience methods like #sum_cost or something later.
If there''s interest, I''d like to adapt the testing portion to
be
included in Rails. I''d much rather type ''rake
testplugin_calculations'' rather than ''cd vendor/plugins/test
&& rake
test_calculations''.
If not, I''ll at least submit a patch so that rake checks the plugins
for added rake files as well. I think checking something like
''vendor/plugins/*/tasks'' would be cool.
[1] http://techno-weenie.net/svn/projects/test/
[2] http://techno-weenie.net/svn/projects/calculations/
--
rick
http://techno-weenie.net