lambdaisland

2022-03-29T23:17:13.153489Z

Façaí looks really good and without actually using it seems like it covers all of the base cases. I appreciate the inclusion of traits, which is one of my favorite features in factory_bot. It seems that traits currently are just alternatives to specified columns in the factory. In fb, they’re a specific context that allows for more complex logic, such as embedding/calling other traits or referencing before/after handlers (which i know isn't part of facai yet). Any plans to implement that logic?

plexus 2022-03-30T04:07:04.165109Z

I'll have to look into that. Got any pointers or good examples?

2022-04-01T16:35:51.665629Z

https://github.com/lambdaisland/facai/issues/1 there you go. I wrote that on my phone so hopefully it's legible.

2022-03-30T14:28:34.278219Z

https://github.com/thoughtbot/factory_bot/blob/37fde91df1b5b1b3bedd73a559f7b299452844ac/GETTING_STARTED.md is the full guide so you can cross reference, but here’s a simple example of a trait referencing another trait:

factory :order do
  trait :completed do
    completed_at { 3.days.ago }
  end

  trait :refunded do
    completed
    refunded_at { 1.day.ago }
  end
end

2022-03-30T15:00:47.330189Z

I would be willing to implement this and/or other factory_bot-style functionality, if you're interested

plexus 2022-03-31T04:58:55.195289Z

Help would definitely be appreciated, but let's then make sure we agree on how it should behave in terms of API. Maybe start with creating an issue for discussion?

👍 1