Skip to content

Instantly share code, notes, and snippets.

@VoltanBro
Last active July 12, 2022 19:11
Show Gist options
  • Select an option

  • Save VoltanBro/fa5e09f3e4efae8c8c28091f974ed63e to your computer and use it in GitHub Desktop.

Select an option

Save VoltanBro/fa5e09f3e4efae8c8c28091f974ed63e to your computer and use it in GitHub Desktop.
advanced factory transient
trait :my_custom do
transient do
params {{}}
end
after(:build) do |field, evaluator|
field.name = evaluator.params[:name]
end
end
# FactoryBot.create(:custom_field, :my_custom, params: { name: 'foo_bar' })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment