Sha256: 20d671f84b7623f63854af06d0913d87c496a10418cf21e77650f143ab1dc9c5
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
require 'spec_helper' describe Grape::Entity do it 'except option for nested entity' do module EntitySpec class Address < Grape::Entity expose :post, if: :full expose :city expose :street expose :house end class Company < Grape::Entity expose :full_name, if: :full expose :name expose :address do |c, o| Address.represent c[:address], Grape::Entity::Options.new(o.opts_hash.except(:full)) end end end company = { full_name: 'full_name', name: 'name', address: { post: '123456', city: 'city', street: 'street', house: 'house', something_else: 'something_else' } } expect(EntitySpec::Company.represent(company).serializable_hash).to eq \ company.slice(:name).merge(address: company[:address].slice(:city, :street, :house)) expect(EntitySpec::Company.represent(company, full: true).serializable_hash).to eq \ company.slice(:full_name, :name).merge(address: company[:address].slice(:city, :street, :house)) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
grape-entity-0.6.1 | spec/grape_entity/hash_spec.rb |
grape-entity-0.6.0 | spec/grape_entity/hash_spec.rb |
grape-entity-0.5.2 | spec/grape_entity/hash_spec.rb |