Sha256: 3e4775123fd414e43199dfcf58f43079d2ccddb317a9ed49ae7e06a29f69dd93

Contents?: true

Size: 517 Bytes

Versions: 4

Compression:

Stored size: 517 Bytes

Contents

require 'spec_helper'

describe Yaks::Mapper::HasOne do
  include_context 'shorthands'

  AuthorMapper = Class.new(Yaks::Mapper) { attributes :name }

  let(:name)     { 'William S. Burroughs' }
  let(:mapper)   { AuthorMapper }
  let(:has_one)  { described_class.new(:author, :author, mapper, [], {}) }
  let(:author)   { Struct.new(:name).new(name) }

  it 'should map to a single Resource' do
    expect(has_one.map_resource(author, {})).to eq resource[{name: name}, [resource_link[:profile, 'author']]]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yaks-0.3.1 spec/yaks/mapper/has_one_spec.rb
yaks-0.3.0 spec/yaks/mapper/has_one_spec.rb
yaks-0.2.0 spec/yaks/mapper/has_one_spec.rb
yaks-0.1.0 spec/yaks/mapper/has_one_spec.rb