Sha256: df126d5ebdf3a7dde37fa71ba661c197c6f774d49ce50bfd96536c1c3b8f7a2e

Contents?: true

Size: 992 Bytes

Versions: 2

Compression:

Stored size: 992 Bytes

Contents

# frozen_string_literal: true

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

describe CSVDecision::Parse do
  it 'loads an empty decision table' do
    table =  CSVDecision.parse('')
    expect(table).to be_a CSVDecision::Table
    expect(table.frozen?).to eq true
    expect(table.rows.empty?).to eq true
  end

  it 'parses a decision table from a CSV file' do
    file = Pathname(File.join(CSVDecision.root, 'spec/data/valid', 'valid.csv'))
    result = CSVDecision.parse(file)

    expected = [
      ['input', '']
    ]

    expect(result).to be_a(CSVDecision::Table)
    expect(result.rows).to eq expected
  end

  context 'it parses valid CSV files' do
    Dir[File.join(CSVDecision.root, 'spec/data/valid/*.csv')].each do |file_name|
      pathname = Pathname(file_name)

      it "loads CSV file: #{pathname.basename}" do
        expect { CSVDecision.parse(pathname) }.not_to raise_error
        expect(CSVDecision.parse(pathname)).to be_a CSVDecision::Table
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
csv_decision-0.0.3 spec/csv_decision/parse_spec.rb
csv_decision-0.0.2 spec/csv_decision/parse_spec.rb