Sha256: a2a144b309a09841b4ef3c566bf4cdada55bd64b0a54391dfe844b8183ae3aa2

Contents?: true

Size: 976 Bytes

Versions: 1

Compression:

Stored size: 976 Bytes

Contents

require 'spec_helper'

RSpec.describe Humanize, "pt locale" do
  before do
    Humanize.configure do |config|
      config.default_locale = :pt
    end
  end

  tests = [
    [8.15, 'oito vírgula um cinco'],
    [1000, 'mil'],
    [1002, 'mil e dois'],
    [2000, 'dois mil'],
    [2002, 'dois mil e um'],
    [10_000, 'dez mil']
  ]

  tests.each do |num, output|
    it "#{num} equals #{output}" do
      expect(num.humanize).to eql(output)
    end
  end

  context 'decimals: number' do
    it 'returns the decimals as whole numbers' do
      num = 8.15
      expect(num.humanize(decimals_as: :number)).to eq('oito vírgula quinze')
    end
  end

  describe 'when called on conceptual number' do
    it 'reads correctly' do
      inf = Float::INFINITY
      neg_inf = -inf
      nan = inf + neg_inf

      expect(inf.humanize).to eql('infinito')
      expect(neg_inf.humanize).to eql('infinito negativo')
      expect(nan.humanize).to eql('indefinido')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
humanize-2.2.0 spec/locales/pt_spec.rb