Hey guys,
I'm trying to upgrade our contentful gem to the most recent version. We are currently still on 0.8. Our test-suite relies on being able to create instances of custom Contentful-class via factory_bot.
Here is an example configuration of a factory:
FactoryBot.define do
factory :category, class: Contentful::Category do
title { FFaker::DizzleIpsum.word }
slug { FFaker::Internet.slug.delete(".") }
end
end
whereas Contentful::Category looks like:
class Contentful::Category < Contentful::Entry
...
end
and is mentioned in the entry_mapping.
Since upgrading to 2.15.3 I have to give factory_bot an initialize_with-methode since Content::FieldsResource requires itemand configuration as parameters (
|
def initialize(item, _configuration, localized = false, includes = [], entries = {}, depth = 0, errors = []) |
)
But initialize_with({},{}) won't do and then I'm in the process of reconstructing real-world contentful-API-responses.
Is there a good way to quickly create instances of Contentful-Custom-Classes without the whole enchilada?
David Litvak Bruno (@dlitvakb) We solved this once waaaay back when #79 ;-)
Hey guys,
I'm trying to upgrade our
contentfulgem to the most recent version. We are currently still on0.8. Our test-suite relies on being able to create instances of custom Contentful-class viafactory_bot.Here is an example configuration of a factory:
whereas
Contentful::Categorylooks like:and is mentioned in the
entry_mapping.Since upgrading to
2.15.3I have to givefactory_botaninitialize_with-methode sinceContent::FieldsResourcerequiresitemandconfigurationas parameters (contentful.rb/lib/contentful/fields_resource.rb
Line 12 in 66961c1
But
initialize_with({},{})won't do and then I'm in the process of reconstructing real-world contentful-API-responses.Is there a good way to quickly create instances of Contentful-Custom-Classes without the whole enchilada?
David Litvak Bruno (@dlitvakb) We solved this once waaaay back when #79 ;-)