How to serialize an object generated by Factorygirl?

Asked

Viewed 27 times

0

I have an object user generated by FactoryGirl like the below:

FactoryGirl.define do
  factory :user do
    name     { FFaker::NameBR.name }
    image    { FFaker::Avatar.image }
    email    { FFaker::Internet.email }
    password 'Passw0rd!'
  end
end

My serializer does not bring image:

module Api::V1
  class UserSerializer < ActiveModel::Serializer
    attributes :id, :name, :email
  end
end

When trying to compare the object generated by the controller and a mock of FactoryGirl I get a comparison error.

expect(json).to eq(JSON.parse(@user.to_json))

My question is how to apply serializer to mock FactoryGirl? Thank you.

  • Maybe the way I’m thinking is wrong, maybe there’s a better alternative, I’d like that feedback. :]

  • 1

    Put here the generated jsons so that we can see the differences

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.