Factory Girl vs. User.create - What's the Difference?

This is an additional note on the Factory Girl question - what is the purpose?

I'm not sure if my question is considered to be recurring, but I'm just still not very clear after reading this post, since I think my doubt is still different.

Okay, so now that we can always use User.create () in the before (: each) block in the Rspec test, why will we still use Factory Girl then?

I got all this confusion when I read Michael Hartle's β€œRails 3 Tutorial,” when he suddenly jumped into Factory Girl, but used User.create () to create the user instance to the end.

I want someone to be able to clarify this moment for me, a lot!

+7
source share
1 answer

You are right, but precious stones, such as a factory girl and manufacturing, can significantly reduce code duplication between clans and within different tests, when you need to test large data sets that require different attribute values ​​due to uniqueness requirements. It mixes in methods to easily β€œproduce” many different objects for these types of tests.

+4
source

All Articles