Sha256: 56c80ed1cf952cc862237c136c42fa24d7eb0f7de84134614dcb787890dae15d

Contents?: true

Size: 718 Bytes

Versions: 1

Compression:

Stored size: 718 Bytes

Contents

require 'spec_helper'

describe 'Wrap operation' do
  subject(:wrap) { relation.wrap(address: [:street, :zipcode, :city]) }

  let(:relation) do
    ROM::Relation.new([{ name: 'Jane',
       email: 'jane@doe.org',
       street: 'Street 1',
       zipcode: '1234',
       city: 'Cracow' }], header).extend(ROM::RA)
  end

  let(:header) do
    [:name, :email, :street, :zipcode, :city]
  end

  it 'wraps given attributes under specified key' do
    expect(wrap.to_a).to eql(
      [{ name: 'Jane',
         email: 'jane@doe.org',
         address: { street: 'Street 1', zipcode: '1234', city: 'Cracow' } }]
    )
  end

  it 'exposes the header' do
    expect(wrap.header).to eql([:name, :email, :address])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-0.4.2 spec/unit/rom/ra/operation/wrap_spec.rb