diff options
| author | 2025-11-26 19:02:28 -0500 | |
|---|---|---|
| committer | 2025-11-26 19:02:28 -0500 | |
| commit | c62f8376a13e7a4f493167aba1c66a9201fc59c6 (patch) | |
| tree | d58492f972be02c406d26620004e1ffe2086fbc7 /test | |
| parent | ae103e148eb3c15606b816505492d870ef062ad3 (diff) | |
New upstream version 3.0.0.upstream/3.0.0upstream
Diffstat (limited to 'test')
| -rw-r--r-- | test/excelx/cell/test_number.rb | 5 | ||||
| -rw-r--r-- | test/files/comments-with-author.xlsx | bin | 0 -> 12524 bytes | |||
| -rw-r--r-- | test/helpers/test_accessing_files.rb | 21 | ||||
| -rw-r--r-- | test/helpers/test_comments.rb | 11 | ||||
| -rw-r--r-- | test/roo/test_open_office.rb | 2 | ||||
| -rw-r--r-- | test/test_helper.rb | 4 | ||||
| -rw-r--r-- | test/test_roo.rb | 2 |
7 files changed, 40 insertions, 5 deletions
diff --git a/test/excelx/cell/test_number.rb b/test/excelx/cell/test_number.rb index ddcffeb..58c9ff7 100644 --- a/test/excelx/cell/test_number.rb +++ b/test/excelx/cell/test_number.rb @@ -35,6 +35,11 @@ class TestRooExcelxCellNumber < Minitest::Test assert_kind_of(Float, cell.value) end + def test_rounded_percent_formatted_value + cell = Roo::Excelx::Cell::Number.new '0.569999999995', nil, ['0%'], nil, nil, nil + assert_equal('57%', cell.formatted_value) + end + def test_formats_with_negative_numbers [ ['#,##0 ;(#,##0)', '(1,042)'], diff --git a/test/files/comments-with-author.xlsx b/test/files/comments-with-author.xlsx Binary files differnew file mode 100644 index 0000000..6377aaf --- /dev/null +++ b/test/files/comments-with-author.xlsx diff --git a/test/helpers/test_accessing_files.rb b/test/helpers/test_accessing_files.rb index 8732bc8..5cccf27 100644 --- a/test/helpers/test_accessing_files.rb +++ b/test/helpers/test_accessing_files.rb @@ -36,6 +36,27 @@ module TestAccesingFiles end end + def test_finalize_twice + skip if defined? JRUBY_VERSION + + instance = Class.new { include Roo::Tempdir }.new + + tempdir = instance.make_tempdir(instance, "my_temp_prefix", nil) + assert File.exist?(tempdir), "Expected #{tempdir} to initially exist" + + pid = Process.fork do + # Inside the forked process finalize does not affect the parent process's state, but does + # delete the tempfile on disk + instance.finalize_tempdirs(instance.object_id) + end + + Process.wait(pid) + refute File.exist?(tempdir), "Expected #{tempdir} to have been cleaned up by child process" + + instance.finalize_tempdirs(instance.object_id) + refute File.exist?(tempdir), "Expected #{tempdir} to still have been cleaned up" + end + def test_cleanup_on_error # NOTE: This test was occasionally failing because when it started running # other tests would have already added folders to the temp directory, diff --git a/test/helpers/test_comments.rb b/test/helpers/test_comments.rb index 2e26786..e204b1a 100644 --- a/test/helpers/test_comments.rb +++ b/test/helpers/test_comments.rb @@ -40,4 +40,15 @@ module TestComments assert_equal expected_comments, oo.comments(oo.sheets.first), "comments error in class #{oo.class}" end end + + def test_excel_comment_with_author + options = { name: "comments-with-author", format: [:excelx] } + expexted_comments = [ + [6, 2, "Eli Wang:\ncomment with author"] + ] + + with_each_spreadsheet(options) do |oo| + assert_equal expexted_comments, oo.comments(oo.sheets.first), "comments error in class #{oo.class}" + end + end end diff --git a/test/roo/test_open_office.rb b/test/roo/test_open_office.rb index 18083a5..897945a 100644 --- a/test/roo/test_open_office.rb +++ b/test/roo/test_open_office.rb @@ -224,7 +224,7 @@ class TestRooOpenOffice < Minitest::Test assert workbook.empty?("C", 1) assert workbook.empty?("D", 1) expected = 1 - letter = "e" + letter = String.new("e") while letter <= "u" assert_equal expected, workbook.cell(letter, 1) letter.succ! diff --git a/test/test_helper.rb b/test/test_helper.rb index 9b761af..2d4fe8f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -80,7 +80,7 @@ def local_server(port) end def start_local_server(filename, port = nil) - require "rack" + require "rackup" content_type = filename.split(".").last port ||= TEST_RACK_PORT @@ -92,7 +92,7 @@ def start_local_server(filename, port = nil) ] end - t = Thread.new { Rack::Handler::WEBrick.run web_server, Host: "0.0.0.0", Port: port , Logger: WEBrick::BasicLog.new(nil,1) } + t = Thread.new { Rackup::Handler::WEBrick.run web_server, Host: "0.0.0.0", Port: port , Logger: WEBrick::BasicLog.new(nil,1) } # give the app a chance to startup sleep(0.2) diff --git a/test/test_roo.rb b/test/test_roo.rb index bd1188d..247c947 100644 --- a/test/test_roo.rb +++ b/test/test_roo.rb @@ -4,8 +4,6 @@ # with the wrong spreadsheet class #STDERR.reopen "/dev/null","w" -Encoding.default_external = "UTF-8" - require 'test_helper' require 'stringio' |
