Sha256: f5db930d27e23b7de0b12ff5f415e0dec929a4d4fb89d3c518868c25d5c0a022

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

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 '<thead><tr><th>test</th><th>the</th>
      <th>header</th></tr></thead>'.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 '<tr><td>aap</td><td>noot</td><td>mies</td></tr>'
      html.must_include '<tr><td>aap</td><td>noot</td><td>mies;</td></tr>'
    end
  end

  it 'must give the correct rowcount' do
    Dir.mktmpdir do |dir|
      filename = File.join(dir, 'test.html')
      output = DocParser::HTMLOutput.new(filename: filename)
      output.header = 'test', 'the', 'header'
      output.rowcount.must_equal 0
      output.add_row %w(aap noot mies)
      output.add_row %w(aap noot mies)
      output.rowcount.must_equal 2
      output.close
      open(filename).read.must_include('<p>2 rows</p>')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
docparser-0.1.4 test/lib/docparser/output/html_output_test.rb
docparser-0.1.3 test/lib/docparser/output/html_output_test.rb