Sha256: 5d40bf241b12dfb7de0ea5949b07c353fd5db94c5b31a8d95289695bb0825eac

Contents?: true

Size: 945 Bytes

Versions: 3

Compression:

Stored size: 945 Bytes

Contents

require 'spec_helper'

module Csv2hash
  module Coercers
    describe YamlCoercer do
      context 'when position is a string' do 
        let(:rules) { {:position=>"Mobile phone number", :key=>"mobile_phone", :allow_blank=>true} }
        let(:result_rules) { {:position=>/\A(Mobile phone number)\z/, :key=>"mobile_phone", :allow_blank=>true} }
        subject { YamlCoercer.new(rules) }

        before { subject.deserialize! }
   
        it{expect(subject.rules).to eql(result_rules)}
      end 

      context 'when position is a array' do 
        let(:rules) { {:position=>[[1,"Mobile phone number"],2], :key=>"mobile_phone", :allow_blank=>true} }
        let(:result_rules) { {:position=>[[1, /Mobile phone number/], 2], :key=>"mobile_phone", :allow_blank=>true} }
        subject { YamlCoercer.new(rules) }

        before { subject.deserialize! }
   
        it{expect(subject.rules).to eql(result_rules)}
      end 
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
csv2hash-0.7.3 spec/csv2hash/yaml_coercer_spec.rb
csv2hash-0.7.2 spec/csv2hash/yaml_coercer_spec.rb
csv2hash-0.7.1 spec/csv2hash/yaml_coercer_spec.rb