Sha256: fe59ea0ec022b6230da60862b47b11c64d1ffb1769505317bf7c8533b366be7d

Contents?: true

Size: 997 Bytes

Versions: 6

Compression:

Stored size: 997 Bytes

Contents

require 'spec_helper'

RSpec.describe 'Mapping domain models to Resource objects' do
  include_context 'fixtures'
  include_context 'yaks context'

  subject { mapper.call(john) }
  let(:mapper) { FriendMapper.new(yaks_context) }

  it { should be_a Yaks::Resource }
  its(:type)         { should eql 'friend' }
  its(:attributes)   { should eql(id: 1, name: 'john') }
  its(:links)        { should eql [ Yaks::Resource::Link.new(:copyright, '/api/copyright/2024', {}) ] }

  its(:subresources) {
    should eq(
      "rel:pet_peeve" => Yaks::Resource.new(type:'pet_peeve', attributes: {id: 4, type: 'parsing with regexps'}),
      "rel:pets" => Yaks::CollectionResource.new(
        type: 'pet',
        members: [
          Yaks::Resource.new(type: 'pet', attributes: {:id => 2, :species => "dog", :name => "boingboing"}),
          Yaks::Resource.new(type: 'pet', attributes: {:id => 3, :species => "cat", :name => "wassup"})
        ],
        collection_rel: 'rel:pets'
      )
    )
  }
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
yaks-0.6.0.alpha.1 spec/integration/map_to_resource_spec.rb
yaks-html-0.6.0.alpha yaks/spec/integration/map_to_resource_spec.rb
yaks-0.6.0.alpha yaks/spec/integration/map_to_resource_spec.rb
yaks-0.5.0 spec/integration/map_to_resource_spec.rb
yaks-0.4.4 spec/integration/map_to_resource_spec.rb
yaks-0.4.3 spec/integration/map_to_resource_spec.rb