Sha256: 76d7ab3f5cbcaf9baf3e8a882de1b57f44631cfbd5cc9138969e912c86328c28

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

require_relative '../../../test_helper'

describe DocParser::XLSXOutput 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.xlsx')
      DocParser::XLSXOutput.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.xlsx')
      output = DocParser::XLSXOutput.new(filename: filename)
      output.header = 'test', 'the', 'header'
      output.close
      sheet = output.instance_variable_get(:@sheet)
      sheet.rows.length.must_equal(1)
    end
  end

  it 'must save some rows' do
    Dir.mktmpdir do |dir|
      filename = File.join(dir, 'test.xlsx')
      output = DocParser::XLSXOutput.new(filename: filename)
      output.add_row ['aap', 'noot', 'mies']
      output.add_row ['aap', 'noot', 'mies;']
      output.close
      sheet = output.instance_variable_get(:@sheet)
      sheet.rows.length.must_equal(2)
    end
  end

  it 'must give the correct rowcount' do
    Dir.mktmpdir do |dir|
      filename = File.join(dir, 'test.xlsx')
      output = DocParser::XLSXOutput.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/xlsx_output_test.rb
docparser-0.1.1 test/lib/docparser/output/xlsx_output_test.rb
docparser-0.1.0 test/lib/docparser/output/xlsx_output_test.rb