How to use 'make' syntax (machinist) in factory_girl 4.0?

94 views
Skip to first unread message

Andy K

unread,
Aug 17, 2012, 5:17:23 PM8/17/12
to factor...@googlegroups.com
Or more precisely, why were the extra syntax classes removed? What is the plan for replacement? Are we supposed to not use them anymore? Write our own require? Include a separate gem?

Lastly, where was this announced / documented?

Thanks,
-Andy

Josh Clayton

unread,
Aug 24, 2012, 10:32:04 AM8/24/12
to factor...@googlegroups.com
Hey Andy,

We removed them because we feel that the syntax introduced in FactoryGirl 2 is the ideal solution; it requires no monkey-patching and works with all ORMs, not just ActiveRecord. There will be no replacement.

We deprecated the alternate syntaxes in 3.2.0 so there would've been a lot of output when running tests warning you that the syntax was removed. Since we're following SemVer, we removed the syntax completely in 4.0. This announcement was made when I released FG 3.2 during RailsConf: http://robots.thoughtbot.com/post/21719164760/factorygirl-3-2-so-awesome-it-needs-to-be-released. We also have a NEWS file (https://github.com/thoughtbot/factory_girl/blob/master/NEWS) that itemizes big changes to the codebase, where it was listed as well.

If you were using RSpec's described_class to piggyback off of the make syntax, we've changed build/create/build_stubbed/attributes_for to accept a class in addition to symbols to refer to the factory - this was done specifically to help during the removal of the alternate syntaxes: https://github.com/thoughtbot/factory_girl/commit/f83c27e15d00beff864be32bf89c6beac33ae0df. This feature was released in 3.4.0, so if you want to rollback to the latest 3.x (3.6.1), you should be all set to convert these over gradually until you're ready to upgrade to 4.0.

Hopefully I covered everything; let me know if you have any more upgrade questions.

Best of luck,
- Josh
Reply all
Reply to author
Forward
0 new messages