Sha256: b2ca381b0afff7364cae52e6028b2c474ce62aeb04db830b398e47020d85dd2a
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
require 'spec_helper' describe FastJsonapi::ObjectSerializer do include_context 'movie class' context 'when testing object serializer with ruby struct' do it 'returns correct hash when serializable_hash is called' do options = {} options[:meta] = { total: 2 } options[:include] = [:actors] serializable_hash = MovieSerializer.new([movie_struct, movie_struct], options).serializable_hash expect(serializable_hash[:data].length).to eq 2 expect(serializable_hash[:data][0][:relationships].length).to eq 3 expect(serializable_hash[:data][0][:attributes].length).to eq 2 expect(serializable_hash[:meta]).to be_instance_of(Hash) expect(serializable_hash[:included]).to be_instance_of(Array) expect(serializable_hash[:included][0]).to be_instance_of(Hash) expect(serializable_hash[:included].length).to eq 3 serializable_hash = MovieSerializer.new(movie_struct).serializable_hash expect(serializable_hash[:data]).to be_instance_of(Hash) expect(serializable_hash[:meta]).to be nil expect(serializable_hash[:included]).to be nil expect(serializable_hash[:data][:id]).to eq movie_struct.id.to_s end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fast_jsonapi-1.0.17 | spec/lib/object_serializer_struct_spec.rb |
fast_jsonapi-1.0.16 | spec/lib/object_serializer_struct_spec.rb |