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.64 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.63 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.62 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.61 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.60 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.59 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.58 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.57 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.56 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.55 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.54 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.53 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.52 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.51 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.50 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.49 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.48 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.47 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.46 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.45 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb