There''s a solution at http://dev.rubyonrails.org/ticket/2404 that mentions overriding the rake tasks to drop the database and load in the schema on each test run. I''d like to do this, but have no clue how, despite plenty of googling. Can anyone help out? Thanks, Pat
I have an entry on my blog, with some code, on how to remove things you don''t want from the Rake processing: http://blog.craz8.com/articles/2005/10/25/rails-application-testing-in-d amage-control In my case, I didn''t want to dump the Development database before loading the Test database, since the machine this is running on has no Development database. To make this happen, I wrote the code to prune out the tasks that dump the Development database. -----Original Message----- From: Pat Maddox [mailto:pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] Sent: Thursday, December 01, 2005 5:52 PM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails] Overriding rake tasks There''s a solution at http://dev.rubyonrails.org/ticket/2404 that mentions overriding the rake tasks to drop the database and load in the schema on each test run. I''d like to do this, but have no clue how, despite plenty of googling. Can anyone help out? Thanks, Pat _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I found that in my searching, but wasn''t able to figure out how to do what I want. Honestly, I''m not even sure exactly what I need to do. I just want to implement the solution in that ticket I linked to earlier...which I think involves dropping the DB and reloading the schema before each test is run. I''m trying to figure out how I can override/extend/modify the rake tasks in order to do that. Pat On 12/1/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:> I have an entry on my blog, with some code, on how to remove things you > don''t want from the Rake processing: > > http://blog.craz8.com/articles/2005/10/25/rails-application-testing-in-d > amage-control > > In my case, I didn''t want to dump the Development database before > loading the Test database, since the machine this is running on has no > Development database. To make this happen, I wrote the code to prune > out the tasks that dump the Development database. > > -----Original Message----- > From: Pat Maddox [mailto:pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] > Sent: Thursday, December 01, 2005 5:52 PM > To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: [Rails] Overriding rake tasks > > There''s a solution at http://dev.rubyonrails.org/ticket/2404 that > mentions overriding the rake tasks to drop the database and load in > the schema on each test run. I''d like to do this, but have no clue > how, despite plenty of googling. Can anyone help out? > > Thanks, > Pat > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
It sounds like you want to use your own DB cloning to load up your schema and data to avoid problems with fixtures and FK constraints. Using my handy Rake addition, you could do something like this in your .rake file: clone_task = Rake::Task.lookup(:clone_structure_to_test) clone_task.remove_prerequisite(:db_structure_dump) clone_task.enhance(:my_custom_db_dump) You would write the ''my_custom_db_dump'' task to save the entire database contents, not just the schema, to the .sql file that the ''clone_structure_to_test'' task is looking for. Or you could work at the next level up to replace the ''clone_structure_to_test'' task with your own that runs a shell script to copy one database to another. -----Original Message----- From: Pat Maddox [mailto:pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] Sent: Thursday, December 01, 2005 6:34 PM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails] Overriding rake tasks I found that in my searching, but wasn''t able to figure out how to do what I want. Honestly, I''m not even sure exactly what I need to do. I just want to implement the solution in that ticket I linked to earlier...which I think involves dropping the DB and reloading the schema before each test is run. I''m trying to figure out how I can override/extend/modify the rake tasks in order to do that. Pat On 12/1/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:> I have an entry on my blog, with some code, on how to remove thingsyou> don''t want from the Rake processing: > >http://blog.craz8.com/articles/2005/10/25/rails-application-testing-in-d> amage-control > > In my case, I didn''t want to dump the Development database before > loading the Test database, since the machine this is running on has no > Development database. To make this happen, I wrote the code to prune > out the tasks that dump the Development database. > > -----Original Message----- > From: Pat Maddox [mailto:pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] > Sent: Thursday, December 01, 2005 5:52 PM > To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: [Rails] Overriding rake tasks > > There''s a solution at http://dev.rubyonrails.org/ticket/2404 that > mentions overriding the rake tasks to drop the database and load in > the schema on each test run. I''d like to do this, but have no clue > how, despite plenty of googling. Can anyone help out? > > Thanks, > Pat > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Still not what I need, I think. Here''s what I want to do. % ruby test/unit/my_unit_test.rb drop database import schema run tests The clone_structure_to_test is fine. What I need to do is make sure that the database is dropped and rebuilt (schema only) before each test suite is run. Right now Rails just deletes the records in the db...which can cause problems when there are constraints. Hopefully I''ve explained myself better. Pat On 12/1/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote:> It sounds like you want to use your own DB cloning to load up your > schema and data to avoid problems with fixtures and FK constraints. > > Using my handy Rake addition, you could do something like this in your > .rake file: > > clone_task = Rake::Task.lookup(:clone_structure_to_test) > clone_task.remove_prerequisite(:db_structure_dump) > clone_task.enhance(:my_custom_db_dump) > > You would write the ''my_custom_db_dump'' task to save the entire database > contents, not just the schema, to the .sql file that the > ''clone_structure_to_test'' task is looking for. > > > Or you could work at the next level up to replace the > ''clone_structure_to_test'' task with your own that runs a shell script to > copy one database to another. > > > -----Original Message----- > From: Pat Maddox [mailto:pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] > Sent: Thursday, December 01, 2005 6:34 PM > To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails] Overriding rake tasks > > I found that in my searching, but wasn''t able to figure out how to do > what I want. Honestly, I''m not even sure exactly what I need to do. > I just want to implement the solution in that ticket I linked to > earlier...which I think involves dropping the DB and reloading the > schema before each test is run. I''m trying to figure out how I can > override/extend/modify the rake tasks in order to do that. > > Pat > > > On 12/1/05, Tom Fakes <Tom-SpgrXpdGZSiNACpsiTyfug@public.gmane.org> wrote: > > I have an entry on my blog, with some code, on how to remove things > you > > don''t want from the Rake processing: > > > > > http://blog.craz8.com/articles/2005/10/25/rails-application-testing-in-d > > amage-control > > > > In my case, I didn''t want to dump the Development database before > > loading the Test database, since the machine this is running on has no > > Development database. To make this happen, I wrote the code to prune > > out the tasks that dump the Development database. > > > > -----Original Message----- > > From: Pat Maddox [mailto:pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] > > Sent: Thursday, December 01, 2005 5:52 PM > > To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > Subject: [Rails] Overriding rake tasks > > > > There''s a solution at http://dev.rubyonrails.org/ticket/2404 that > > mentions overriding the rake tasks to drop the database and load in > > the schema on each test run. I''d like to do this, but have no clue > > how, despite plenty of googling. Can anyone help out? > > > > Thanks, > > Pat > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >