require_relative '../../../test_helper'
describe DocParser::HTMLOutput 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.html')
DocParser::HTMLOutput.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.html')
output = DocParser::HTMLOutput.new(filename: filename)
output.header = 'test', 'the', 'header'
output.close
open(filename).read.must_include ' '.gsub(/\s+/, '')
end
end
it 'must save some rows' do
Dir.mktmpdir do |dir|
filename = File.join(dir, 'test.html')
output = DocParser::HTMLOutput.new(filename: filename)
output.add_row %w(aap noot mies)
output.add_row ['aap', 'noot', 'mies;']
output.close
html = open(filename).read
html.must_include 'tbody'
html.must_include 'test the
header
2 rows
') end end end