FactoryBot helper or README update
Hey! Thanks for your work! The gem works great!
What do you think about factory_bot helper especially for this gem? Or maybe README update about how to create factories.
I've spent half a hour to figure out how to create working factory for my model with has_one_base64_attached :avatar.
So, I succeed with this code
FactoryBot.define do
factory :user do
avatar do
image_url = Faker::LoremFlickr.image
image_data = URI.open(image_url).read
{ data: "data:image/png;base64, #{Base64.strict_encode64(image_data)}" }
end
end
end
Adding the whole string to hash as value by key data was not obvious in the beginning.
FactoryBot helper will be something like that:
FactoryBot.define do
factory :user do
avatar do
image_url = Faker::LoremFlickr.image
image_data = URI.open(image_url).read
base64_attached(image_data)
end
end
end
I would be happy to make a contribution. You must just choose:
- README update
OR
- FactoryBot helper
Waiting for your decision :seal:
Hey @kalashnikovisme, thanks for your contribution. I think providing a FactoryBot helper would be a better approach, thanks for the suggestion!