【问题标题】:Rspec test that uses active model serializer in nested engine not passing在嵌套引擎中使用活动模型序列化程序的 Rspec 测试未通过
【发布时间】:2021-03-25 05:22:21
【问题描述】:
... 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 ...

AnimalSerializer 位于 animal_engine/app/serializers/api_handler/api/private/mobile_app/v8 中

奇怪地序列化单个项目。

我收到以下错误

UncaughtThrowError:未捕获的抛出:no_serializer

【问题讨论】:

    标签: ruby-on-rails rspec rspec-rails active-model-serializers activemodel


    【解决方案1】:

    使用 :serializer 而不是 :each_serializer。不知道为什么它失败了,但它修复了它。

    【讨论】:

      猜你喜欢
      • 2019-01-16
      • 2016-09-03
      • 2017-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-09
      • 1970-01-01
      • 2018-01-16
      相关资源
      最近更新 更多