Testing ActiveModelSerializer


#1

I am trying to test ActiveModelSerializer (https://github.com/rails-api/active_model_serializers) but having facing some trouble.

I created a plain rails api project and the tests run successfully (Repo: https://github.com/ratneshraval/serializer-rails)

When using jets api, I played around but couldn’t get past the following error. (Repo: https://github.com/ratneshraval/serializer-jets)

undefined method `assert_serializer' for #<RSpec::ExampleGroups::TodosController::GETIndex:0x00007ff1423cfbc8>

When including ActiveModelSerializers::Test::Schema, ActiveModelSerializers::Test::Serializer I get following error.

 undefined method `setup' for RSpec::ExampleGroups::TodosController:Class

Any help would be appreciated.
Thanks


#2

Added 3 types of tests in this PR (https://github.com/ratneshraval/serializer-jets/pull/1)
Made some changes to reflect API mode of jets.
Adjusted some requires in spec_helper.rb

You’ll see 3 different types of errors.

  1. undefined methodfiltered_parameters’ for #Jets::SpecHelpers::Request:0x00007fdf49c2e6a8`
  2. undefined methodassert_serializer’ for #RSpec::ExampleGroups::TodosController::GETIndex:0x00007fdf4d3e4d90`
  3. undefined methodassert’ for #RSpec::ExampleGroups::TodosController::GETIndex:0x00007fdf4e8c8798`

#3

@tung Have you had a chance to look at this?
Any help of setting up Rspec testing with these kind of external libraries would be appreciated.


#4

Nope. Haven’t looked, unsure when.