Sha256: 5b9ade9bc9e4d68cdb4ff12cd939ccecb23d32bf4268e80bc9caeb7dbd0f1ae2

Contents?: true

Size: 873 Bytes

Versions: 1

Compression:

Stored size: 873 Bytes

Contents

# frozen_string_literal: true

require_relative '../../lib/csv_decision2'

describe CSVDecision2::Load do
  path = Pathname(File.join(CSVDecision2.root, 'spec/data/valid'))

  it "loads all valid CSV files in the directory" do
    tables = CSVDecision2.load(path, first_match: false, regexp_implicit: true)
    expect(tables).to be_a Hash
    expect(tables.count).to eq Dir[path.join('*.csv')].count

    tables.each_pair do |name, table|
      expect(name).to be_a(Symbol)
      expect(table).to be_a(CSVDecision2::Table)
    end
  end

  it 'rejects an invalid path name' do
    expect { CSVDecision2.load('path') }
      .to raise_error(ArgumentError, 'path argument must be a Pathname')
  end

  it 'rejects an invalid folder name' do
    expect { CSVDecision2.load(Pathname('path')) }
      .to raise_error(ArgumentError, 'path argument not a valid folder')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
csv_decision2-0.5.2 spec/csv_decision2/load_spec.rb