I'd like to migrate my fixtures to "Factory Girl" in Rails.
Is there any easy way to convert all yml files in a factories.rb file?
I'd like to migrate my fixtures to "Factory Girl" in Rails.
Is there any easy way to convert all yml files in a factories.rb file?
I am assuming what you are looking to do is find a script which will look through your models and generate the factories for them. I tried this once (with something other than factory_girl) and found it full of bad data.
I would suggest that you slowly transition to using factories. As you write new tests or update old ones, create the necessary factories. As time goes by, if you have the time and energy you can then choose an individual test case and replace all the fixtured data calls with the proper factory calls and remove the specific fixture requirement at the top of the test case.
I've just released a gem called fix_to_chix a few days ago to address the exact same issue.
It probably needs a lot of enhancements, but it might help you: http://github.com/caike/fix_to_chix (you need to copy and paste it on your browser since SO seems to put some chars in the url)
What exactly would you expect the resulting factories to be? The whole idea of Factories is that you don't have to maintain a long list of test data. Instead, the data is created on the fly, close to your tests, where it should be.