Sha256: 39fa449cb81bea21763ef4bbad02adf92059cb0f6b03ef3f2303a6fdddbb5c20

Contents?: true

Size: 747 Bytes

Versions: 2

Compression:

Stored size: 747 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Mapper::Dumper, '#call' do
  subject(:dumper) { described_class.new(header) }

  let(:header) { Mapper::Header.build([[:uid, Integer], [:name, String]], map: { uid: :id }, keys: [:uid]) }
  let(:data)   { Hash[id: 1, name: 'Jane'] }
  let(:model)  { mock_model(:id, :name) }
  let(:object) { model.new(data) }

  context 'with public attribute readers' do
    it 'returns dumped tuple' do
      expect(dumper.call(object)).to eq([1, 'Jane'])
    end
  end

  context 'with private attribute readers' do
    before do
      model.send(:private, :id)
      model.send(:private, :name)
    end

    it 'returns dumped tuple' do
      expect(dumper.call(object)).to eq([1, 'Jane'])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rom-mapper-0.1.1 spec/unit/rom/mapper/dumper/call_spec.rb
rom-mapper-0.1.0 spec/unit/rom/mapper/dumper/call_spec.rb