require 'spec_helper'

describe Xform do
  subject {Xform::RorXform.new }


    describe '#process_incoming' do
      context 'with a `+` as a delimiter' do
        let(:incoming) { 'survey +age 15 +name Emily Karungi +gender female'}
        let(:output) { subject.process_incoming(incoming)}

        it 'responds to calls to field' do
          expect(output['age']).to eq '15' # Integer type field
          expect(output['name']).to eq 'emily karungi' # String type
          expect(output['gender']).to eq 'female' # String type
        end
      end

      context 'with a `.` as a delimiter' do
        let(:incoming) { 'survey .age 15 .name Emily Karungi .gender female'}
        let(:output) { subject.process_incoming(incoming, {'delimiter'=> '.'})}
        it 'responds to calls to field' do
          expect(output['age']).to eq '15' # Integer type field
          expect(output['name']).to eq 'emily karungi' # String type
          expect(output['gender']).to eq 'female' # String type
        end
      end
  end

end
