From a2578f893df0f5b9536190b4ee075013969b0a67 Mon Sep 17 00:00:00 2001 From: Siong Date: Thu, 20 Nov 2014 13:23:15 -0800 Subject: [PATCH] add spec for `default_serializer_options`. --- spec/grape-active_model_serializers/formatter_spec.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/grape-active_model_serializers/formatter_spec.rb b/spec/grape-active_model_serializers/formatter_spec.rb index 0529e9d..bed4a93 100644 --- a/spec/grape-active_model_serializers/formatter_spec.rb +++ b/spec/grape-active_model_serializers/formatter_spec.rb @@ -41,6 +41,10 @@ describe Grape::Formatter::ActiveModelSerializers do def endpoint.current_user @current_user ||= User.new(first_name: 'Current user') end + + def endpoint.default_serializer_options + { only: :only, except: :except } + end end subject { described_class.fetch_serializer(user, env) } @@ -48,7 +52,12 @@ describe Grape::Formatter::ActiveModelSerializers do it { should be_a UserSerializer } it 'should have correct scope set' do - expect(subject.scope).to eq(endpoint.current_user) + expect(subject.scope.current_user).to eq(endpoint.current_user) + end + + it 'should read default serializer options' do + expect(subject.instance_variable_get('@only')).to eq([:only]) + expect(subject.instance_variable_get('@except')).to eq([:except]) end end end