Sha256: 4a9a7b1ba0627fb24b3396a4cfdafac56ac1556d226e96b71c8ba04763475d8f
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
require 'helper' require 'peddler/flat_file_parser' class FlatFileParserTest < MiniTest::Test def setup body = "Feed Processing Summary:\n\tNumber of records processed\t\t11006\n\tNumber of records successful\t\t11006\n\noriginal-record-number\tsku\terror-code\terror-type\terror-message\n1822\t85da472e-ba6c-11e3-95af-002590a74356\t5000\tWarning\tThe update for Sku '85da472e-ba6c-11e3-95af-002590a74356' was skipped because it is identical to the update in feed '9518995390'.\n" body.encode!('ASCII-8BIT') headers = { 'Content-Type' => 'application/octet-stream', 'Content-MD5' => 'SmZIMTs2mCO8u8QzR5LE7Q==' } res = OpenStruct.new(body: body, headers: headers) @parser = Peddler::FlatFileParser.new(res, 'ISO-8859-1') end def test_parses_data assert_kind_of CSV::Table, @parser.parse end def test_summarises refute_empty @parser.records_count end def test_validates assert @parser.valid? end def test_handles_reports_without_a_summary res = OpenStruct.new(body: "Foo\nBar\n") parser = Peddler::FlatFileParser.new(res, 'ISO-8859-1') refute_empty parser.content end def test_handles_japanese_flat_files body = "Foo\nこんにちは\n" body.encode!('SHIFT_JIS') body.force_encoding('ASCII-8BIT') res = OpenStruct.new(body: body) parser = Peddler::FlatFileParser.new(res, 'SHIFT_JIS') assert_equal 'こんにちは', parser.parse[0]['Foo'] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
peddler-0.7.7 | test/unit/peddler/test_flat_file_parser.rb |
peddler-0.7.6 | test/unit/peddler/test_flat_file_parser.rb |