Sha256: 7791953970b79b2acb2ca6de1cad226f2f09ea69f74d69825c6931a64efca9f4

Contents?: true

Size: 1.1 KB

Versions: 9

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

module Csv2hash
  describe YamlLoader do
    subject { YamlLoader.new config_file }
    before  { subject.load! }

    context 'yml' do
      let(:config_file) { 'config/rules.yml.erb' }

      specify do
        expect(subject.definition.name).to eql('example')
        expect(subject.definition.header_size).to eql(2)
        expect(subject.definition.cells.last.rules.fetch(:values)).to eql(18..90)
      end
    end

    context 'erb' do
      let(:config_file) { 'config/rules.yml' }

      specify do
        expect(subject.definition.name).to eql('example')
        expect(subject.definition.header_size).to eql(2)
      end
    end

    context 'extra validator' do
      let(:config_file) { 'config/rules.extra_validator.yml.erb' }

      specify do
        expect(subject.definition.name).to eql('example')
        expect(subject.definition.header_size).to eql(0)
        expect(subject.definition.cells.first.rules.fetch(:extra_validator)).to be_a(DowncaseValidator)
        expect(subject.definition.cells.last.rules.fetch(:position)[0][1]).to eql(/LastName/)
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
csv2hash-0.7.7 spec/csv2hash/yaml_loader_spec.rb
csv2hash-0.7.6 spec/csv2hash/yaml_loader_spec.rb
csv2hash-0.7.5 spec/csv2hash/yaml_loader_spec.rb
csv2hash-0.7.3 spec/csv2hash/yaml_loader_spec.rb
csv2hash-0.7.2 spec/csv2hash/yaml_loader_spec.rb
csv2hash-0.7.1 spec/csv2hash/yaml_loader_spec.rb
csv2hash-0.7.0 spec/csv2hash/yaml_loader_spec.rb
csv2hash-0.6.8 spec/csv2hash/yaml_loader_spec.rb
csv2hash-0.6.7 spec/csv2hash/yaml_loader_spec.rb