简体   繁体   中英

Rspec test that uses active model serializer in nested engine not passing

... serialized_animals = ActiveModel::Serializer::CollectionSerializer.new(animals, each_serializer: ApiHandler::Api::Private::MobileApp::V8::AnimalSerializer)
          aggregate_failures 'response details' do
            expect(JSON.parse(response.body)['data']['animals']).to(eq(JSON.parse(serialized_animals.to_json)))
          end ...

The AnimalSerializer sits in animal_engine/app/serializers/api_handler/api/private/mobile_app/v8

Weirdly serializing a single item works.

I get the following error

UncaughtThrowError: uncaught throw:no_serializer

Use:serializer instead of:each_serializer. Not sure why it was failing but that fixes it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM