How to implement: with_trait using Fabrication

I am considering moving many layouts from FactoryGirl to the Fabrication gem.

However, so far I have not been able to find information on using the trait pattern available in FactoryGirl.

Is there a common way to do this with Fabrication?

Thanks in advance for any answers or information.

+6
source share
1 answer

There is no syntactic sugar for tags in the manufacture. As I understand it, this is just a way of grouping and defining inheritance.

In the case of this Factory: (which I pulled from this blog post )

FactoryGirl.define do factory :todo_item, aliases: [:incomplete_todo_item] do name 'Pick up a gallon of milk' complete false factory :complete_todo_item do complete true end end end 

You would do the same in Fabrication like this:

 Fabricator(:todo_item, aliases: :incomplete_todo_item) do name 'Pick up a gallon of milk' complete false end Fabricator(:complete_todo_item, from: :todo_item) do complete true end 

If you decide to convert, you can send to the mailing list with any specific questions. I am always happy to help you figure out how to get things done or increase the efficiency of your manufacturers.

+6
source

Source: https://habr.com/ru/post/984700/


All Articles