# Unit test preperation with migrations

**URL:** <https://www.ruby-forum.com/t/unit-test-preperation-with-migrations/123344>\
**Category:** Rails\
**Created:** [December 16, 2007, 7:29pm UTC](https://www.ruby-forum.com/t/unit-test-preperation-with-migrations/123344 "2007-12-16T19:29:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pozza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8e8cbc/32.png) [@pozza](https://www.ruby-forum.com/u/pozza)\
**Post date:** [December 16, 2007, 7:29pm UTC](https://www.ruby-forum.com/t/unit-test-preperation-with-migrations/123344/1 "2007-12-16T19:29:49Z")

</div>

I have spent sometime this afternoon learning how to unit test rails  
applications and integrate the Cerberus CI tool. One key area confuses  
me however, and I would appreciate other peoples views of how best to  
overcome the issue.

My understanding is that the ‘test’ and ‘test:units’ have the  
db:test:prepare pre-requisite which copies the schema from dev to the  
test database. I would prefer to use migrations to perform the building  
of the test schema, and I have tried  
‘[http://snippets.dzone.com/posts/show/2031](http://snippets.dzone.com/posts/show/2031)’ to use migration building.  
However, this still attempts to use ‘dropdb’ and ‘createdb’ commands  
when using the rake test. I know this is some kind of setup /  
registration problem, but I wanted confirmation that these kind of  
‘tweaks’ to the rails app is the best way of implementing the migration  
control over the test db.

What are your thoughts and apologies if there are similar posts on this  
topic, but I have spent some time searching!!!

---

<div class="post-metadata">

**Author:** ![pozza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8e8cbc/32.png) [@pozza](https://www.ruby-forum.com/u/pozza)\
**Post date:** [December 16, 2007, 7:37pm UTC](https://www.ruby-forum.com/t/unit-test-preperation-with-migrations/123344/2 "2007-12-16T19:37:36Z")

</div>

Hi –

On Sun, 16 Dec 2007, Paul Williams wrote:

> ‘[http://snippets.dzone.com/posts/show/2031](http://snippets.dzone.com/posts/show/2031)’ to use migration building.  
> However, this still attempts to use ‘dropdb’ and ‘createdb’ commands  
> when using the rake test. I know this is some kind of setup /  
> registration problem, but I wanted confirmation that these kind of  
> ‘tweaks’ to the rails app is the best way of implementing the migration  
> control over the test db.
> 
> What are your thoughts and apologies if there are similar posts on this  
> topic, but I have spent some time searching!!!

I’m probably guilty of taking a very unsophisticated approach but what  
I normally do is:

rake db:migrate RAILS\_ENV=test

David

–  
Training for 2008!  
Ruby on Rails training by David A. Black/Ruby Power and Light, LLC:  
\* Intro to Rails, New York, NY, February 4-7 2008  
\* Advancing With Rails, New York, NY, February 11-14 2008  
Hosted by Exceed Education. See [http://www.rubypal.com](http://www.rubypal.com) for details!
