Last active
October 21, 2020 22:38
-
-
Save leboshi/e0e6302b50eaef325744087048f16924 to your computer and use it in GitHub Desktop.
Roo bug: floating-point values in "0%"-formatted cells are truncated instead of rounded by :formatted_value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'bundler/inline' | |
gemfile(true) do | |
source 'https://rubygems.org' | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem 'minitest' | |
gem 'roo' | |
end | |
require 'minitest/autorun' | |
require 'roo' | |
class PercentageFloatRoundingTest < Minitest::Test | |
def test_cell_value_rounds_percentage_formatted_value | |
spreadsheet = Roo::Spreadsheet.open("percentage_float_test.xlsx") | |
cell = spreadsheet.sheet_for('Sheet1').cells[[1, 1]] | |
assert_equal '57%', cell.formatted_value | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce
Download spreadsheet and script above and run; you may need to modify the file path on line 19.
Expected behavior
Test should pass. The spreadsheet contains a single cell with the value
57%
as a0%
-formatted percentage.:formatted_value
should return"57%"
.Actual behavior
:formatted_value
returns56%
.PR incoming!