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.84 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.83 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.82 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.81 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.80 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.79 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.78 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.77 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.76 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.75 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.74 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.73 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.72 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.71 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.70 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.69 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.68 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.67 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.66 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.65 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb