lambdaisland 2022-03-29

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?

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

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

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

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

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