Skip to content

Instantly share code, notes, and snippets.

@bassemawhoob
Last active August 23, 2023 11:00
Show Gist options
  • Save bassemawhoob/4d55c269cdd5ea352c02a99d865aadaa to your computer and use it in GitHub Desktop.
Save bassemawhoob/4d55c269cdd5ea352c02a99d865aadaa to your computer and use it in GitHub Desktop.
FactoryBot - Conditional Traits
traits = [(:with_shipment if condition?)].compact
create(:advice, *traits)

Or inline:

create(:advice, *[(:with_shipment if condition?)].compact)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment