spec/unit/yaks/mapper/has_many_spec.rb in yaks-0.4.1 vs spec/unit/yaks/mapper/has_many_spec.rb in yaks-0.4.2

- old
+ new

@@ -1,27 +1,35 @@ require 'spec_helper' RSpec.describe Yaks::Mapper::HasMany do - let(:closet_mapper) do + include_context 'yaks context' + + let(:closet_mapper) { closet_mapper_class.new(yaks_context) } + + let(:closet_mapper_class) do Class.new(Yaks::Mapper) do type 'closet' has_many :shoes, rel: 'http://foo/shoes', mapper: Class.new(Yaks::Mapper) { type 'shoe' ; attributes :size, :color } end end + subject(:shoe_association) { closet_mapper.associations.first } + + its(:singular_name) { should eq 'shoe' } + let(:closet) { double( :shoes => [ double(size: 9, color: :blue), double(size: 11.5, color: :red), ] ) } it 'should map the subresources' do - expect(closet_mapper.new(policy: Yaks::DefaultPolicy.new, env: {}).call(closet).subresources).to eql( + expect(closet_mapper.call(closet).subresources).to eql( "http://foo/shoes" => Yaks::CollectionResource.new( type: 'shoe', members: [ Yaks::Resource.new(type: 'shoe', attributes: {:size => 9, :color => :blue}), Yaks::Resource.new(type: 'shoe', attributes: {:size => 11.5, :color => :red})