Sha256: 313adb5ace9ffb5be9fd0ba68dd8d5a96c81d2b13004e31783a6fa3b819a50c1
Contents?: true
Size: 1.1 KB
Versions: 15
Compression:
Stored size: 1.1 KB
Contents
require 'test_helper' # This tests the NdrImport::FixedWidth::Table mapping class module FixedWidth class TableTest < ActiveSupport::TestCase def test_transform_fixed_width_line table = NdrImport::FixedWidth::Table.new(header_lines: 2, footer_lines: 1, klass: 'SomeTestKlass', columns: fixed_width_column_mapping) enum = table.transform_line('123 abcdexyz', 2) assert_instance_of Enumerator, enum output = [] enum.each do |klass, fields, index| output << [klass, fields, index] end expected_output = [ ['SomeTestKlass', { rawtext: { 'one' => '123 ', 'two' => 'abcde', 'three' => 'xyz' } }, 2] ] assert_equal expected_output.sort, output.sort end private def fixed_width_column_mapping [ { 'column' => 'one', 'unpack_pattern' => 'a5' }, { 'column' => 'two', 'unpack_pattern' => 'a5' }, { 'column' => 'three', 'unpack_pattern' => 'a3' } ] end end end
Version data entries
15 entries across 15 versions & 1 rubygems