FactoryBot skip_create
factory_bot has an option to skip calling save!
on create:
FactoryBot.define do
factory :model_without_table do
skip_create
an_attribute { "An Attribute" }
end
end
This will build the object in memory, but not persist it. Useful if you want to create a factory for a model that isn't backed by a database table, where trying to persist the record would result in an exception.
Tweet