Sha256: 707bec3bb51e8e48f14975717c79ea9a40a3f48f1d547a2c76f7ced0f5c55234

Contents?: true

Size: 919 Bytes

Versions: 124

Compression:

Stored size: 919 Bytes

Contents

# frozen_string_literal: true

RSpec.describe :number_to_percentage do
  link :number_to_percentage, from: :ree_number

  it {
    expect(number_to_percentage(100)).to eq("100.000%")
    expect(number_to_percentage(Float::NAN)).to eq("NaN%")
    expect(number_to_percentage(Float::INFINITY)).to eq("Inf%")
    
    expect(number_to_percentage(Float::NAN, precision: 1)).to eq("NaN%")
    expect(number_to_percentage(Float::INFINITY, precision: 1)).to eq("Inf%")
    expect(number_to_percentage("-0.13", format: "%n %", precision: 2)).to eq("-0.13 %")
    expect(number_to_percentage(1000, format: "%n  %")).to eq("1000.000  %")
    expect(number_to_percentage(123.400, precision: 3, strip_insignificant_zeros: true)).to eq("123.4%")
    expect(number_to_percentage(1.25, precision: 2, significant: true)).to eq("1.3%")
    expect(number_to_percentage(302.0574, precision: 2, round_mode: :down)).to eq("302.05%")
  }
end

Version data entries

124 entries across 124 versions & 1 rubygems

Version Path
ree_lib-1.0.124 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.123 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.122 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.121 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.120 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.119 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.118 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.117 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.116 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.115 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.114 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.113 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.112 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.111 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.110 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.109 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.108 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.107 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.106 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.105 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb