Sha256: 72c0bd24dd63a2c390d6282b689a76ec3f3e8a7e231288b146b052b5ff3336f4
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
# frozen_string_literal: true require_relative '../../lib/csv_decision2' describe CSVDecision2::Input do it 'rejects a non-hash or empty hash value' do expect { CSVDecision2::Input.parse(table: nil, input: [], symbolize_keys: true ) } .to raise_error(ArgumentError, 'input must be a non-empty hash') expect { CSVDecision2::Input.parse(table: nil, input: {}, symbolize_keys: true ) } .to raise_error(ArgumentError, 'input must be a non-empty hash') end it 'processes input hash with symbolize_keys: true' do data = <<~DATA IN :input, OUT :output, IN: input1 input0, output0, input1 input0, output1, DATA table = CSVDecision2.parse(data) input = { 'input' => 'input0', input1: 'input1' } expected = { hash: { input: 'input0', input1: 'input1' }, scan_cols: { 0 => 'input0', 2 => 'input1'}, key: 'input0' } result = CSVDecision2::Input.parse(table: table, input: input, symbolize_keys: true) expect(result).to eql expected expect(result[:hash]).not_to equal expected[:hash] end it 'processes input hash with symbolize_keys: false' do data = <<~DATA IN :input, OUT :output, IN: input1 input0, output0, input1 input0, output1, DATA table = CSVDecision2.parse(data) input = { input: 'input0', input1: 'input1' } expected = { hash: input, scan_cols: { 0 => 'input0', 2 => 'input1'}, key: 'input0' } result = CSVDecision2::Input.parse(table: table, input: input, symbolize_keys: false) expect(result).to eql expected expect(result[:hash]).to equal expected[:hash] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csv_decision2-0.5.2 | spec/csv_decision2/input_spec.rb |