Sha256: a11d54489dbe0002a264108beb262ce65c11a67c234ccc8427df4438b56a2419

Contents?: true

Size: 865 Bytes

Versions: 18

Compression:

Stored size: 865 Bytes

Contents

# frozen_string_literal: true

require_relative '../../lib/csv_decision'

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

  it "loads all valid CSV files in the directory" do
    tables = CSVDecision.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(CSVDecision::Table)
    end
  end

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

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

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
csv_decision2-0.5.1 spec/csv_decision/load_spec.rb
csv_decision-0.5.1 spec/csv_decision/load_spec.rb
csv_decision-0.5.0 spec/csv_decision/load_spec.rb
csv_decision-0.4.1 spec/csv_decision/load_spec.rb
csv_decision-0.4.0 spec/csv_decision/load_spec.rb
csv_decision-0.3.2 spec/csv_decision/load_spec.rb
csv_decision-0.3.1 spec/csv_decision/load_spec.rb
csv_decision-0.3.0 spec/csv_decision/load_spec.rb
csv_decision-0.2.0 spec/csv_decision/load_spec.rb
csv_decision-0.1.0 spec/csv_decision/load_spec.rb
csv_decision-0.0.9 spec/csv_decision/load_spec.rb
csv_decision-0.0.8 spec/csv_decision/load_spec.rb
csv_decision-0.0.7 spec/csv_decision/load_spec.rb
csv_decision-0.0.6 spec/csv_decision/load_spec.rb
csv_decision-0.0.5 spec/csv_decision/load_spec.rb
csv_decision-0.0.4 spec/csv_decision/load_spec.rb
csv_decision-0.0.3 spec/csv_decision/load_spec.rb
csv_decision-0.0.2 spec/csv_decision/load_spec.rb