Sha256: 3334b7b743f78c26c3e98515eeeb23c86dba018051c83edf8762ba4877c03cc7

Contents?: true

Size: 951 Bytes

Versions: 2

Compression:

Stored size: 951 Bytes

Contents

require 'spec_helper'

describe DataMaps::Then::Convert do
  subject { DataMaps::Then::Convert.new({ map: { a: 'x', b: 'y' }, ruby: [:join, ','] }) }

  describe 'initialization' do
    it 'Creates the converter' do
      expect(subject.converter.length).to eq 2
      expect(subject.converter[0]).to be_a DataMaps::Converter::Map
      expect(subject.converter[1]).to be_a DataMaps::Converter::Ruby
    end

    it 'converter has the correct options' do
      expect(subject.converter[0].option).to eq({ 'a' => 'x', 'b' => 'y' })
      expect(subject.converter[1].option).to eq [:join, ',']
    end
  end

  describe '#execute' do
    it 'calls the given converter ordered' do
      data = %w[ a b ]
      expect(subject.converter[0]).to receive(:execute).with(data).and_return(data).ordered
      expect(subject.converter[1]).to receive(:execute).with(data).and_return(data).ordered

      expect(subject.execute(data)).to eq data
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
data_maps-0.2.0 spec/data_maps/then/convert_spec.rb
data_maps-0.1.0 spec/data_maps/then/convert_spec.rb