Sha256: 893ae233a265b88236ab1f5267720dde6bfb6621f1fb897b95c85ddc1b04058f
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 KB
Contents
require 'spec_helper' RSpec.describe Yaks::DefaultPolicy do subject(:policy) { described_class.new( options ) } let(:options) { {} } let(:association) { Yaks::Mapper::HasMany.new(name: 'shoes', collectionMapper: nil) } describe '#initialize' do it 'should work without arguments' do expect(described_class.new.options).to eql described_class::DEFAULTS end let(:options) { {foo: :bar} } it 'should merge default and given options' do expect(policy.options.values_at(:namespace, :foo)).to eql [Kernel, :bar] end end describe '#derive_type_from_mapper_class' do specify do expect( policy.derive_type_from_mapper_class(Namespace::RyeMapper) ).to eql 'rye' end end describe '#derive_mapper_from_association' do let(:options) { { namespace: Namespace } } it 'should derive using the singular association name, and look inside the namespace' do expect(policy.derive_mapper_from_association(association)).to be Namespace::ShoeMapper end end describe '#derive_rel_from_association' do it 'should expand the rel based on the association name' do expect(policy.derive_rel_from_association(association)).to eql 'rel:shoes' end end describe '#expand_rel' do let(:options) { { rel_template: 'http://foo/{?rel}' } } it 'should expand the given template' do expect(policy.expand_rel('rockets')).to eql 'http://foo/?rel=rockets' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yaks-0.4.4 | spec/unit/yaks/default_policy_spec.rb |
yaks-0.4.3 | spec/unit/yaks/default_policy_spec.rb |