test/test_workbook.rb in writeexcel-0.3.5 vs test/test_workbook.rb in writeexcel-0.4.0
- old
+ new
@@ -1,20 +1,18 @@
+# -*- coding: utf-8 -*-
require 'helper'
require "stringio"
class TC_Workbook < Test::Unit::TestCase
def setup
- t = Time.now.strftime("%Y%m%d")
- path = "temp#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
- @test_file = File.join(Dir.tmpdir, path)
+ @test_file = StringIO.new
@workbook = Workbook.new(@test_file)
end
def teardown
@workbook.close
- File.unlink(@test_file) if FileTest.exist?(@test_file)
end
def test_new
assert_kind_of(Workbook, @workbook)
end
@@ -80,28 +78,9 @@
=end
def test_raise_set_compatibility_after_sheet_creation
@workbook.add_worksheet
assert_raise(RuntimeError) { @workbook.compatibility_mode }
- end
-
- def test_write_to_io
- # write to @test_file
- @workbook.add_worksheet
- @workbook.close
- file = ''
- File.open(@test_file, "rb") do |f|
- file = f.read
- end
-
- # write to io
- io = StringIO.new
- wb = Workbook.new(io)
- wb.add_worksheet
- wb.close
-
- # compare @test_file and io
- assert_equal(file, io.string)
end
def valid_sheetname
[
# Tests for valid names