How to apply serializer to an object generated by FactoryGirl?

0

I have an object user generated by FactoryGirl like the one 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 have 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 of FactoryGirl ? Thank you.

    
asked by anonymous 22.11.2016 / 13:07

0 answers