Sha256: 7c61b955d69f94fb4cafac51cafe9b15036a6597022bfb03511b2496a67825c2
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
require 'helper' class TestJson2Csv < Test::Unit::TestCase SEPS = {:comma => ',', :pipe => '|', :semicolon => ';'} should "parse some test files" do fixtures_dir = File.expand_path(File.join(File.dirname(__FILE__), 'json2csv-fixtures')) Dir.chdir(fixtures_dir) do Dir.glob('*.json') do |filename| basename = File.basename(filename, ".json") print "Testing json2csv against #{filename}\n" SEPS.each do |key, val| template = "#{basename}_#{key.to_sym}.csv" print " ... for comparison with #{template} " headers = ['thumbpath','imgpath','imgsrc','width','height','thumbsrc','thumbwidth','thumbheight'] input = File.read(filename) output = StringIO.new() JSON2CSV.parse(input, output, headers, {:col_sep => val} ) output.pos = 0 fileToCompareTo = File.read(template) assert_equal output.read.strip, fileToCompareTo.strip print "OK\n" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csv2json-0.3.0 | test/test_json2csv.rb |