From 5767664c8a7890a3bdb2e80d0437e8c042e0985f Mon Sep 17 00:00:00 2001 From: Daniel Duke Date: Fri, 4 Jan 2019 09:12:58 -0800 Subject: [PATCH] add specs for multiple include options --- spec/lib/object_serializer_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/lib/object_serializer_spec.rb b/spec/lib/object_serializer_spec.rb index c86ce7c..42db8f0 100644 --- a/spec/lib/object_serializer_spec.rb +++ b/spec/lib/object_serializer_spec.rb @@ -142,12 +142,25 @@ describe FastJsonapi::ObjectSerializer do expect { MovieSerializer.new([movie, movie], options).serializable_hash }.to raise_error(ArgumentError) end + it 'returns errors when serializing with non-existent and existent includes keys' do + options = {} + options[:meta] = { total: 2 } + options[:include] = [:actors, :blah_blah] + expect { MovieSerializer.new([movie, movie], options).serializable_hash }.to raise_error(ArgumentError) + end + it 'does not throw an error with non-empty string array includes key' do options = {} options[:include] = ['actors'] expect { MovieSerializer.new(movie, options) }.not_to raise_error end + it 'does not throw an error with non-empty string array includes keys' do + options = {} + options[:include] = ['actors', 'owner'] + expect { MovieSerializer.new(movie, options) }.not_to raise_error + end + it 'returns keys when serializing with empty string/nil array includes key' do options = {} options[:meta] = { total: 2 }