Time ago I learnt how to use stored procedures in Ruby on Rails, but I couldn’t understand how to use them in test. rake test consistently failed to copy my stored procedures from the development to the test database so there was little left to test there.
After upgrading to Rails 1.1.6 I started a new project and this time I made it.
The winning move was uncommenting this line in environment.rb
config.active_record.schema_format = :sql
Rails creates the db/development_structure.sql file now which contains my development database structure, stored procedures included. When I run rake test it uses this file to create the test database and the test code has all it needs to run.