Migrating from Machinist / Named Blueprints -> Named Fabricators

35 views
Skip to first unread message

Rob Lacey

unread,
Nov 19, 2013, 6:17:58 AM11/19/13
to fabrica...@googlegroups.com
Hi there,

We're considering migrating from Machinist because Machinist 1 has had no commits for 3 years. I was wondering if Fabrication has a way of using 'named Fabricators' in the same way that you have 'named Blueprints' in Machinist.

The only way I can see at the moment to do this would be instead of

User.blueprint(:admin) do
  admin true
end

User.make(:admin)

You'd have say...

Fabricator(:admin_user, :from => :user) do
  admin true
end

Fabricate(:admin_user)

Anyone got any other ideas?

Cheers

RobL

Paul Elliott

unread,
Nov 19, 2013, 8:53:51 AM11/19/13
to fabrica...@googlegroups.com
You could achieve what you are doing today with machinist like this:

Fabricator(:admin, class_name: ‘User’) do
  admin true
end

You can also provide aliases in Fabrication which may come in handy for you.

Fabricator(:admin, class_name: ‘User’, aliases: %i(user_admin super_user)) do
  admin true
end

That way they can be fabricated using any of the above names.

-- Paul

--
You received this message because you are subscribed to the Google Groups "fabrication" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fabricationge...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Rob Lacey

unread,
Nov 22, 2013, 5:47:25 AM11/22/13
to fabrica...@googlegroups.com
Thanks very much for that Paul, it works for me :)
Reply all
Reply to author
Forward
0 new messages