So while I don't love doing this, an easy way to prevent the initializer from running during db:migrate, but running on application start or test run is to wrap it in a clause testing if the table exists. So if you take your existing initializer code and wrap it in
if ActiveRecord::Base.connection.table_exists? 'table_name'
....
end
where 'table_name' is the name of the missing table, then both rake db:migrate and the spec run should be able to complete successfully.