Sha256: 9af00d2a5014e34089caf560eac0f33776c39058a0a1ccce500ade4f75c4e92b

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

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

describe DocParser::XLSXOutput do
  it 'must create a file' do
    Dir.mktmpdir do |dir|
      filename = File.join(dir, 'test.xlsx')
      DocParser::XLSXOutput.new(filename: filename)
      File.exist?(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 %w[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 %w[aap noot mies]
      output.add_row %w[aap noot mies]
      output.rowcount.must_equal 2
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
docparser-0.3.0 test/lib/docparser/output/xlsx_output_test.rb