Is there a rake command in Rails 3 to clone my development database data? I noticed rake db:test:prepare
and rake db:test:clone
are mentioned throughout various blogs, but running them seems to do nothing. Furthermore, rake -T
shows no db:test
cases. I've resorted to loading a sql dump for now, but it would be great if I could just clone my existing development data for up-to-date testing.
EDIT --
I desire to test on a database since I am dealing with legacy data that I run through model filters when accessed. Factories won't work for me in this context, since data passed through create
is defined as a different schema than that of the legacy data.
rake db:test:prepare
is still there even though it doesn't show up in rake -Tdb
. I guess the Rails team decided to de-clutter the rake -T
output?
I would suggest you not clone your development database but rather rely on factories to give you predictable data you can craft for your exact test cases. Sooner or later, relying on having reliable test data in a database you can access will break your tests. It will also break the tests of anyone else who works on the project. And changes/additions to the data will not propagate to other developers as would your carefully constructed factories.
Look over Machinist, FixJour, FactoryGirl and the lot. They really solve the test data problem well and you check them into version control so the rest of your team has access to them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With