Sha256: 082e75ea2c62ce8a00302bbfa25e91d96203025faf6b6511311669a5d71acb33
Contents?: true
Size: 1.89 KB
Versions: 3
Compression:
Stored size: 1.89 KB
Contents
require_relative '../../../test_helper' describe DocParser::YAMLOutput do before do Log4r::Logger['docparser'].level = Log4r::ERROR end after do Log4r::Logger['docparser'].level = Log4r::INFO end it 'must create a file' do Dir.mktmpdir do |dir| filename = File.join(dir, 'test.yml') DocParser::YAMLOutput.new(filename: filename) File.exists?(filename).must_equal true end end it 'must save the header' do Dir.mktmpdir do |dir| filename = File.join(dir, 'test.yml') output = DocParser::YAMLOutput.new(filename: filename) output.header = 'test', 'the', 'header' output.close open(filename).read.must_equal '' end end it 'must have a header' do Dir.mktmpdir do |dir| filename = File.join(dir, 'test.yml') output = DocParser::YAMLOutput.new(filename: filename) -> do output.add_row ['aap', 'noot', 'mies'] end.must_raise(DocParser::MissingHeaderException) end end it 'must save some rows' do Dir.mktmpdir do |dir| filename = File.join(dir, 'test.csv') output = DocParser::YAMLOutput.new(filename: filename) output.header = 'test', 'the', 'header' output.add_row ['a', 'b', 'c'] output.add_row ['aap', 'noot', 'mies"'] output.add_row ['aap', 'noot'] # testing empty column output.close open(filename).read.must_equal <<-YAMLEND --- test: a the: b header: c --- test: aap the: noot header: mies\" --- test: aap the: noot header: '' YAMLEND end end it 'must give the correct rowcount' do Dir.mktmpdir do |dir| filename = File.join(dir, 'test.yml') output = DocParser::YAMLOutput.new(filename: filename) output.header = 'test', 'the', 'header' output.rowcount.must_equal 0 output.add_row ['aap', 'noot', 'mies'] output.add_row ['aap', 'noot', 'mies'] output.rowcount.must_equal 2 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
docparser-0.1.2 | test/lib/docparser/output/yaml_output_test.rb |
docparser-0.1.1 | test/lib/docparser/output/yaml_output_test.rb |
docparser-0.1.0 | test/lib/docparser/output/yaml_output_test.rb |