Closed
Description
With this simple serializer:
class ExerciseEquipmentSerializer < ActiveModel::Serializer
attributes :id, :name
end
and then this test:
require 'spec_helper'
describe ExerciseEquipmentSerializer do
let(:exercise_equipment) { create :exercise_equipment }
let(:serializer) { ExerciseEquipmentSerializer.new exercise_equipment }
let(:result) { JSON.parse(serializer.to_json) }
it "huh?" do
expect(result).to eq id: 1, name: 'name'
end
end
I get this:
expected: {:id=>1, :name=>"name"}
got: {"object"=>{"id"=>1, "name"=>"name", "description"=>"description", "image"=>{"url"=>nil}, "created_at"=>"2015-04-22T20:52:06.794Z", "updated_at"=>"2015-04-22T20:52:06.794Z"}, "options"=>{}, "root"=>false, "meta"=>nil, "meta_key"=>nil, "scope"=>nil}
(compared using ==)
Diff:
@@ -1,3 +1,7 @@
-:id => 1,
-:name => "name",
+"meta" => nil,
+"meta_key" => nil,
+"object" => {"id"=>1, "name"=>"name", "description"=>"description", "image"=>{"url"=>nil}, "created_at"=>"2015-04-22T20:52:06.794Z", "updated_at"=>"2015-04-22T20:52:06.794Z"},
+"options" => {},
+"root" => false,
+"scope" => nil,
which seems a bit odd compared to what I was getting before in 0.8.x...