Convert Lighting to Factory Girl in Rails

I would like to transfer my lights to Factory Girl in Rails.

Is there an easy way to convert all yml files to factories.rb file?

+4
source share
3 answers

I guess what you want to do is find a script that will look at your models and create factories for them. I tried this once (with something other than factory_girl), and found that it is full of bad data.

I would suggest that you move slowly to using factories. When you write new tests or update old ones, create the necessary factories. After the lapse of time, if you have time and energy, you can select an individual test case and replace all calls with verified data using the corresponding factory calls and delete the specific fastening requirement at the top of the test case.

+6
source

I just released a gem called fix_to_chix a few days ago to address the exact same problem.

It probably needs a lot of improvements, but it can help you: http://github.com/caike/fix_to_chix (you need to copy and paste it into your browser since SO seems to put some characters in the url)

+1
source

What exactly do you expect from the resulting plants? The whole idea of โ€‹โ€‹factories is that you do not need to maintain a long list of test data. Instead, data is created on the fly, next to your tests, where it should be.

0
source

All Articles