Sha256: 60a72877144323dd7666516c5490d27819150c72ca9abd941062501bf1ce4c53
Contents?: true
Size: 1.95 KB
Versions: 19
Compression:
Stored size: 1.95 KB
Contents
# -*- coding: utf-8 -*- require 'helper' require 'write_xlsx/workbook' require 'write_xlsx/worksheet' require 'stringio' class TestWriteHeaderFooter < Minitest::Test def setup @workbook = WriteXLSX.new(StringIO.new) @worksheet = @workbook.add_worksheet('') @writer = @worksheet.instance_variable_get(:@writer) end def test_write_odd_header @worksheet.set_header('Page &P of &N') @worksheet. instance_variable_get(:@page_setup). __send__('write_odd_header', @writer) result = @writer.string expected = '<oddHeader>Page &P of &N</oddHeader>' assert_equal(expected, result) end def test_write_odd_footer @worksheet.set_footer('&F') @worksheet. instance_variable_get(:@page_setup). __send__('write_odd_footer', @writer) result = @worksheet.instance_variable_get(:@writer).string expected = '<oddFooter>&F</oddFooter>' assert_equal(expected, result) end def test_write_haeder_footer_only_header @worksheet.set_header('Page &P of &N') @worksheet.__send__('write_header_footer') result = @worksheet.instance_variable_get(:@writer).string expected = '<headerFooter><oddHeader>Page &P of &N</oddHeader></headerFooter>' assert_equal(expected, result) end def test_write_haeder_footer_only_footer @worksheet.set_footer('&F') @worksheet.__send__('write_header_footer') result = @worksheet.instance_variable_get(:@writer).string expected = '<headerFooter><oddFooter>&F</oddFooter></headerFooter>' assert_equal(expected, result) end def test_write_haeder_footer_both_header_and_footer @worksheet.set_header('Page &P of &N') @worksheet.set_footer('&F') @worksheet.__send__('write_header_footer') result = @worksheet.instance_variable_get(:@writer).string expected = '<headerFooter><oddHeader>Page &P of &N</oddHeader><oddFooter>&F</oddFooter></headerFooter>' assert_equal(expected, result) end end
Version data entries
19 entries across 19 versions & 1 rubygems