Sha256: a5cb2563f92f56a21dabdc885e6c18459aa91050965856159eb9868ddf1a96d1

Contents?: true

Size: 1.34 KB

Versions: 10

Compression:

Stored size: 1.34 KB

Contents

# -*- coding: utf-8 -*-
require 'helper'

class TestCheckSheetname < Minitest::Test
  def setup
    @workbook = WriteXLSX.new(StringIO.new)
    @workbook.add_worksheet
  end

  def test_check_sheetname_duplicate_names
    duplicate_names = ['Sheet1', 'sheet1']

    duplicate_names.each do |sheetname|
      assert_raises RuntimeError, "'#{sheetname}' passed incorrectly" do
        @workbook.add_worksheet(sheetname)
      end
    end
  end

  def test_check_sheetname_invalid_characters
    invalid_characters = [
      'Sheet[', 'Sheet]', 'Sheet:', 'Sheet*', 'Sheet/', 'Sheet\\'
    ]

    invalid_characters.each do |sheetname|
      assert_raises RuntimeError, "'#{sheetname}' passed incorrectly" do
        @workbook.add_worksheet(sheetname)
      end
    end
  end

  def test_check_sheetname_long_name
    long_name = ['name_that_is_longer_than_thirty_one_characters']

    long_name.each do |sheetname|
      assert_raises RuntimeError, "'#{sheetname}' passed incorrectly" do
        @workbook.add_worksheet(sheetname)
      end
    end
  end

  def test_check_sheetname_invalid_start_stop_character
    invalid_start_end_character = ["Sheet'", "'Sheet", "'Sheet'"]

    invalid_start_end_character.each do |sheetname|
      assert_raises RuntimeError, "'#{sheetname}' passed incorrectly" do
        @workbook.add_worksheet(sheetname)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
write_xlsx-1.09.4 test/workbook/test_check_sheetname.rb
write_xlsx-1.09.3 test/workbook/test_check_sheetname.rb
write_xlsx-1.09.2 test/workbook/test_check_sheetname.rb
write_xlsx-1.09.1 test/workbook/test_check_sheetname.rb
write_xlsx-1.09.0 test/workbook/test_check_sheetname.rb
write_xlsx-1.08.2 test/workbook/test_check_sheetname.rb
write_xlsx-1.08.1 test/workbook/test_check_sheetname.rb
write_xlsx-1.08.0 test/workbook/test_check_sheetname.rb
write_xlsx-1.07.0 test/workbook/test_check_sheetname.rb
write_xlsx-1.04.0 test/workbook/test_check_sheetname.rb