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.44 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.43 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.42 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.41 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.40 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.39 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.38 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.37 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.36 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.35 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.34 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.33 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.32 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.31 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.30 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.29 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.28 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.27 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.26 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb
ree_lib-1.0.24 lib/ree_lib/packages/ree_number/spec/ree_number/functions/number_to_percentage_spec.rb