test/test_05_rows.rb in writeexcel-0.3.5 vs test/test_05_rows.rb in writeexcel-0.4.0
- old
+ new
@@ -1,5 +1,6 @@
+# -*- coding: utf-8 -*-
###############################################################################
#
# A test for WriteExcel.
#
# Check that max/min columns of the Excel ROW record are written correctly.
@@ -9,21 +10,20 @@
# original written in Perl by John McNamara
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
#
############################################################################
require 'helper'
+require 'stringio'
class TC_rows < Test::Unit::TestCase
def setup
end
def test_1
- t = Time.now.strftime("%Y%m%d")
- path = "temp#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
- @test_file = File.join(Dir.tmpdir, path)
- workbook = WriteExcel.new(@test_file)
+ file = StringIO.new
+ workbook = WriteExcel.new(file)
workbook.compatibility_mode(1)
@tests = []
# for test case 1
row = 1
@@ -148,11 +148,12 @@
workbook.biff_only = 1
workbook.close
# Read in the row records
rows = []
- xlsfile = open(@test_file, "rb")
+ xlsfile = StringIO.new(file.string)
+
while header = xlsfile.read(4)
record, length = header.unpack('vv')
data = xlsfile.read(length)
#read the row records only
@@ -171,9 +172,8 @@
assert_equal(@tests[i][1], rows[i], @tests[i][0])
end
end
def teardown
- File.unlink(@test_file) if FileTest.exist?(@test_file)
end
end