diff options
Diffstat (limited to 'activesupport/test/core_ext/numeric_ext_test.rb')
-rw-r--r-- | activesupport/test/core_ext/numeric_ext_test.rb | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/activesupport/test/core_ext/numeric_ext_test.rb b/activesupport/test/core_ext/numeric_ext_test.rb index fc93a18ab1..5e824747ed 100644 --- a/activesupport/test/core_ext/numeric_ext_test.rb +++ b/activesupport/test/core_ext/numeric_ext_test.rb @@ -176,7 +176,6 @@ class NumericExtFormattingTest < ActiveSupport::TestCase assert_equal("£1234567890,50", 1234567890.50.to_s(:currency, unit: "£", separator: ",", delimiter: "")) end - def test_to_s__rounded assert_equal("-111.235", -111.2346.to_s(:rounded)) assert_equal("111.235", 111.2346.to_s(:rounded)) @@ -222,7 +221,6 @@ class NumericExtFormattingTest < ActiveSupport::TestCase assert_equal "12.345.678,05", 12345678.05.to_s(:delimited, delimiter: ".", separator: ",") end - def test_to_s__rounded_with_custom_delimiter_and_separator assert_equal "31,83", 31.825.to_s(:rounded, precision: 2, separator: ",") assert_equal "1.231,83", 1231.825.to_s(:rounded, precision: 2, separator: ",", delimiter: ".") @@ -350,13 +348,13 @@ class NumericExtFormattingTest < ActiveSupport::TestCase def test_number_to_human_with_custom_units #Only integers - volume = {unit: "ml", thousand: "lt", million: "m3"} + volume = { unit: "ml", thousand: "lt", million: "m3" } assert_equal "123 lt", 123456.to_s(:human, units: volume) assert_equal "12 ml", 12.to_s(:human, units: volume) assert_equal "1.23 m3", 1234567.to_s(:human, units: volume) #Including fractionals - distance = {mili: "mm", centi: "cm", deci: "dm", unit: "m", ten: "dam", hundred: "hm", thousand: "km"} + distance = { mili: "mm", centi: "cm", deci: "dm", unit: "m", ten: "dam", hundred: "hm", thousand: "km" } assert_equal "1.23 mm", 0.00123.to_s(:human, units: distance) assert_equal "1.23 cm", 0.0123.to_s(:human, units: distance) assert_equal "1.23 dm", 0.123.to_s(:human, units: distance) @@ -369,20 +367,20 @@ class NumericExtFormattingTest < ActiveSupport::TestCase assert_equal "12.3 km", 12300.to_s(:human, units: distance) #The quantifiers don't need to be a continuous sequence - gangster = {hundred: "hundred bucks", million: "thousand quids"} + gangster = { hundred: "hundred bucks", million: "thousand quids" } assert_equal "1 hundred bucks", 100.to_s(:human, units: gangster) assert_equal "25 hundred bucks", 2500.to_s(:human, units: gangster) assert_equal "25 thousand quids", 25000000.to_s(:human, units: gangster) assert_equal "12300 thousand quids", 12345000000.to_s(:human, units: gangster) #Spaces are stripped from the resulting string - assert_equal "4", 4.to_s(:human, units: {unit: "", ten: "tens "}) - assert_equal "4.5 tens", 45.to_s(:human, units: {unit: "", ten: " tens "}) + assert_equal "4", 4.to_s(:human, units: { unit: "", ten: "tens " }) + assert_equal "4.5 tens", 45.to_s(:human, units: { unit: "", ten: " tens " }) end def test_number_to_human_with_custom_format assert_equal "123 times Thousand", 123456.to_s(:human, format: "%n times %u") - volume = {unit: "ml", thousand: "lt", million: "m3"} + volume = { unit: "ml", thousand: "lt", million: "m3" } assert_equal "123.lt", 123456.to_s(:human, units: volume, format: "%n.%u") end |