To run automated tests for your Ruby on Rails webapp, not only do you need your latest database structure deployed to the test database (created by
rake db:test:prepare), but you also need some seed data for lookup tables, e.g. like zip codes.
Common approaches like adding seed data through rails migrations are discouraged, and plugins like seed_fu only work for small amounts of seed data. In seed_fu, you can specify a
seed method for your ActiveRecord models like so:
User.seed(:login, :email) do |s| s.login = "bob" s.email = "[email protected]" s.first_name = "Bob" s.last_name = "Bobson" end
rake db:seed task provided by seed_fu will add all defined models to your test database.
DHH has even standardized a way to load seed data for Rails 3, making the
rake db:seed task part of rails and setting up a file called
db/seeds.rb for maintaining your seeding code. Using that file, you can load your seed data however you see fit, e.g. seed_fu.