add spec for default_serializer_options.

This commit is contained in:
Siong 2014-11-20 13:23:15 -08:00
parent cfb80be11e
commit a2578f893d

View file

@ -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