Sha256: f19b4c783b4d2b6100839836b5734de703f85308a98a857694afd60e70df6dd3

Contents?: true

Size: 716 Bytes

Versions: 4

Compression:

Stored size: 716 Bytes

Contents

require 'spec_helper'

describe 'Wrap operation' do
  subject(:wrap) { relation.in_memory { 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)
  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

4 entries across 4 versions & 1 rubygems

Version Path
rom-0.4.1 spec/unit/rom/ra/operation/wrap_spec.rb
rom-0.4.0 spec/unit/rom/ra/operation/wrap_spec.rb
rom-0.3.1 spec/unit/rom/ra/operation/wrap_spec.rb
rom-0.3.0 spec/unit/rom/ra/operation/wrap_spec.rb