Sha256: 7cb4be42a7a3b6bd13b93db350d76d594aa442a20cc117a166455afaa29f09fe

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

require "assert"

require 'xmlss/element/worksheet'

module Xmlss::Element
  class WorksheetTest < Assert::Context
    desc "Xmlss::Worksheet"
    before { @wksht = Worksheet.new('sheet') }
    subject { @wksht }

    should have_class_method :writer
    should have_accessor :name

    should "know its writer hook" do
      assert_equal :worksheet, subject.class.writer
    end

    should "set it's defaults" do
      assert_equal 'sheet', subject.name
    end

    should "filter name chars" do
      # worksheet name cannot contain: /, \, :, ;, * or start with '['
      assert_equal "test test", Worksheet.new("test/ test").name
      assert_equal "test test", Worksheet.new("tes\\t test").name
      assert_equal "test test", Worksheet.new("te:st test:").name
      ws = Worksheet.new("te;st ;test")
      assert_equal "test test", ws.name
      ws.name = "t*est test"
      assert_equal "test test", ws.name
      ws.name = "[te]st test"
      assert_equal "te]st test", ws.name
      ws.name = "t[e]st test"
      assert_equal "t[e]st test", ws.name
    end

    should "complain if given a name longer than 31 chars" do
      assert_raises ArgumentError do
        Worksheet.new('a'*32)
      end
      assert_nothing_raised do
        Worksheet.new('a'*31)
      end
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xmlss-1.0.0.rc.4 test/element/worksheet_test.rb
xmlss-1.0.0.rc.3 test/element/worksheet_test.rb
xmlss-1.0.0.rc.2 test/element/worksheet_test.rb
xmlss-1.0.0.rc.1 test/element/worksheet_test.rb